OSDN Git Service

* tree-scalar-evolution.c (follow_ssa_edge_in_rhs,
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 9 Jun 2007 21:34:08 +0000 (21:34 +0000)
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 9 Jun 2007 21:34:08 +0000 (21:34 +0000)
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.

* gcc.dg/tree-ssa/loop-28.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125595 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfghooks.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/loop-28.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c

index ab0c225..830517d 100644 (file)
@@ -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.
index 8852ca9..98b5e34 100644 (file)
@@ -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
index bc45908..821e1c5 100644 (file)
@@ -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 (file)
index 0000000..19f0ac5
--- /dev/null
@@ -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" } } */
index 0598361..a5444ab 100644 (file)
@@ -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;