summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/cfghooks.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/loop-28.c24
-rw-r--r--gcc/tree-scalar-evolution.c21
5 files changed, 57 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ab0c2259876..830517d3b4e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-09 Zdenek Dvorak <dvorakz@suse.cz>
+
+ * tree-scalar-evolution.c (follow_ssa_edge_in_rhs,
+ follow_ssa_edge_in_condition_phi, follow_ssa_edge): Keep more precise
+ track of the size of the expression.
+ * cfghooks.c (merge_blocks): Remove block from loops structure only
+ after call of the merge_blocks hook.
+
2007-06-09 Tom Tromey <tromey@redhat.com>
* c-decl.c (grokdeclarator): Added 'deprecated_state' argument.
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 8852ca91f4f..98b5e349e70 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -646,11 +646,11 @@ merge_blocks (basic_block a, basic_block b)
if (!cfg_hooks->merge_blocks)
internal_error ("%s does not support merge_blocks", cfg_hooks->name);
+ cfg_hooks->merge_blocks (a, b);
+
if (current_loops != NULL)
remove_bb_from_loops (b);
- cfg_hooks->merge_blocks (a, b);
-
/* Normally there should only be one successor of A and that is B, but
partway though the merge of blocks for conditional_execution we'll
be merging a TEST block with THEN and ELSE successors. Free the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bc45908ac6b..821e1c569c3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-09 Zdenek Dvorak <dvorakz@suse.cz>
+
+ * gcc.dg/tree-ssa/loop-28.c: New testcase.
+
2007-06-09 Ian Lance Taylor <iant@google.com>
PR tree-optimization/32169
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-28.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-28.c
new file mode 100644
index 00000000000..19f0ac5c184
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-28.c
@@ -0,0 +1,24 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-O2 -fprefetch-loop-arrays -march=athlon -fdump-tree-final_cleanup -fdump-tree-aprefetch --param max-unrolled-insns=1000" } */
+
+char x[100000];
+
+void foo(int n)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ x[i] = (char) i;
+}
+
+/* There should be 64 MEMs in the unrolled loop and one more in the copy of the loop
+ for the rest of the iterations. */
+
+/* { dg-final { scan-tree-dump-times "MEM" 65 "final_cleanup" } } */
+
+/* There should be no i_a = i_b assignments. */
+/* { dg-final { scan-tree-dump-times "i_.*= i_\[0-9\]*;" 0 "aprefetch" } } */
+
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */
+/* { dg-final { cleanup-tree-dump "aprefetch" } } */
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 059836154a6..a5444abb384 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -1056,6 +1056,12 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
{
/* Match an assignment under the form:
"a = b + c". */
+
+ /* We want only assignments of form "name + name" contribute to
+ LIMIT, as the other cases do not necessarily contribute to
+ the complexity of the expression. */
+ limit++;
+
evol = *evolution_of_loop;
res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
@@ -1141,6 +1147,13 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
{
/* Match an assignment under the form:
"a = b - ...". */
+
+ /* We want only assignments of form "name - name" contribute to
+ LIMIT, as the other cases do not necessarily contribute to
+ the complexity of the expression. */
+ if (TREE_CODE (rhs1) == SSA_NAME)
+ limit++;
+
res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
evolution_of_loop, limit);
if (res == t_true)
@@ -1255,6 +1268,10 @@ follow_ssa_edge_in_condition_phi (struct loop *loop,
*evolution_of_loop = evolution_of_branch;
+ /* If the phi node is just a copy, do not increase the limit. */
+ if (PHI_NUM_ARGS (condition_phi) > 1)
+ limit++;
+
for (i = 1; i < PHI_NUM_ARGS (condition_phi); i++)
{
/* Quickly give up when the evolution of one of the branches is
@@ -1338,7 +1355,7 @@ follow_ssa_edge (struct loop *loop, tree def, tree halting_phi,
return t_false;
/* Give up if the path is longer than the MAX that we allow. */
- if (limit++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
+ if (limit > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
return t_dont_know;
def_loop = loop_containing_stmt (def);
@@ -1369,7 +1386,7 @@ follow_ssa_edge (struct loop *loop, tree def, tree halting_phi,
/* Inner loop. */
if (flow_loop_nested_p (loop, def_loop))
return follow_ssa_edge_inner_loop_phi
- (loop, def, halting_phi, evolution_of_loop, limit);
+ (loop, def, halting_phi, evolution_of_loop, limit + 1);
/* Outer loop. */
return t_false;