diff options
author | Richard Guenther <rguenther@suse.de> | 2009-04-02 09:10:53 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-04-02 09:10:53 +0000 |
commit | bf1cbdc6e43e3a62ef6ecac786ac70ecf5851ef6 (patch) | |
tree | 1a6f6d8f33ade81a49b8870ef8209f8ef2aa991e | |
parent | 4bb7dbf60ef02a1172371a21e44533aa717a533a (diff) | |
download | gcc-bf1cbdc6e43e3a62ef6ecac786ac70ecf5851ef6.zip gcc-bf1cbdc6e43e3a62ef6ecac786ac70ecf5851ef6.tar.gz gcc-bf1cbdc6e43e3a62ef6ecac786ac70ecf5851ef6.tar.bz2 |
re PR middle-end/37221 (Missed early loop-unroll optimization - causes 40% degradation on SPU)
2009-04-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37221
* tree-flow.h (degenerate_phi_result): Declare.
* tree-ssa-dom.c (degenerate_phi_result): Export.
* tree-scalar-evolution.c (analyze_initial_condition): If
the initial condition is defined by a degenerate PHI node
use the degenerate value.
* gcc.c-torture/compile/20090331-1.c: New testcase.
From-SVN: r145439
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20090331-1.c | 26 | ||||
-rw-r--r-- | gcc/tree-flow.h | 1 | ||||
-rw-r--r-- | gcc/tree-scalar-evolution.c | 14 | ||||
-rw-r--r-- | gcc/tree-ssa-dom.c | 2 |
6 files changed, 56 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b3b7d78..8305ab1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2009-04-02 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37221 + * tree-flow.h (degenerate_phi_result): Declare. + * tree-ssa-dom.c (degenerate_phi_result): Export. + * tree-scalar-evolution.c (analyze_initial_condition): If + the initial condition is defined by a degenerate PHI node + use the degenerate value. + 2009-04-01 Eric Botcazou <ebotcazou@adacore.com> PR rtl-optimization/39588 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b61f69a..48b2e9d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-04-02 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/37221 + * gcc.c-torture/compile/20090331-1.c: New testcase. + 2009-04-01 Eric Botcazou <ebotcazou@adacore.com> * gcc.c-torture/compile/20090401-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20090331-1.c b/gcc/testsuite/gcc.c-torture/compile/20090331-1.c new file mode 100644 index 0000000..2db2ee7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20090331-1.c @@ -0,0 +1,26 @@ +struct re_pattern_buffer { + unsigned char *buffer; + unsigned long int allocated; +}; +void byte_regex_compile (struct re_pattern_buffer *bufp, + unsigned char *begalt, unsigned char *b) +{ + unsigned char *pfrom; + unsigned char *pto; + + while ((unsigned long) (b - bufp->buffer + 3) > bufp->allocated) + { + unsigned char *old_buffer = bufp->buffer; + bufp->allocated <<= 1; + if (old_buffer != bufp->buffer) + { + int incr = bufp->buffer - old_buffer; + b += incr; + } + } + pfrom = b; + pto = b + 3; + while (pfrom != begalt) + *--pto = *--pfrom; +} + diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 07fb9be..868b762 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -919,6 +919,7 @@ bool simplify_stmt_using_ranges (gimple_stmt_iterator *); extern void dump_dominator_optimization_stats (FILE *); extern void debug_dominator_optimization_stats (void); int loop_depth_of_name (tree); +tree degenerate_phi_result (gimple); /* In tree-ssa-copy.c */ extern void merge_alias_info (tree, tree); diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 8e12c2b..af959b7 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1577,6 +1577,20 @@ analyze_initial_condition (gimple loop_phi_node) if (init_cond == chrec_not_analyzed_yet) init_cond = chrec_dont_know; + /* During early loop unrolling we do not have fully constant propagated IL. + Handle degenerate PHIs here to not miss important unrollings. */ + if (TREE_CODE (init_cond) == SSA_NAME) + { + gimple def = SSA_NAME_DEF_STMT (init_cond); + tree res; + if (gimple_code (def) == GIMPLE_PHI + && (res = degenerate_phi_result (def)) != NULL_TREE + /* Only allow invariants here, otherwise we may break + loop-closed SSA form. */ + && is_gimple_min_invariant (res)) + init_cond = res; + } + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " (init_cond = "); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 6d6d02b..c252a72 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -2475,7 +2475,7 @@ avail_expr_eq (const void *p1, const void *p2) /* Given PHI, return its RHS if the PHI is a degenerate, otherwise return NULL. */ -static tree +tree degenerate_phi_result (gimple phi) { tree lhs = gimple_phi_result (phi); |