]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/66375 (wrong code at -O2 and -O3 on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Wed, 3 Jun 2015 07:57:13 +0000 (07:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 3 Jun 2015 07:57:13 +0000 (07:57 +0000)
2015-06-03  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66375
* tree-scalar-evolution.c (follow_ssa_edge_binary): First
add to the evolution before following SSA edges.

* gcc.dg/torture/pr66375.c: New testcase.

From-SVN: r224060

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr66375.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c

index 07743bba32e61d2e317d63a8ce000b07f12ff128..06dda145fd6243383ca5ff718c36e197f84ad63d 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66375
+       * tree-scalar-evolution.c (follow_ssa_edge_binary): First
+       add to the evolution before following SSA edges.
+
 2015-06-03  Bin Cheng  <bin.cheng@arm.com>
 
        * tree-ssa-loop-ivopts.c (dump_iv): New parameter.
index 3abe065e648ed7f7d783148d190b2281e6624ee1..9fd5941e979772378c35129fc384c532ee7e51cd 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66375
+       * gcc.dg/torture/pr66375.c: New testcase.
+
 2015-06-03  Bin Cheng  <bin.cheng@arm.com>
 
        * gcc.dg/tree-ssa/pr65447.c: Increase searching number.
diff --git a/gcc/testsuite/gcc.dg/torture/pr66375.c b/gcc/testsuite/gcc.dg/torture/pr66375.c
new file mode 100644 (file)
index 0000000..2447b43
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+
+int a;
+extern void abort (void);
+int main ()
+{
+  int c = 0;
+  for (; a < 13; ++a)
+    c = (signed char)c - 11;
+  if (c != 113)
+    abort ();
+  return 0;
+}
index 013fc507830569aeef1d45aa6352df42094829d3..3a2c284b5826777daf53a453ac2288f408c97fe4 100644 (file)
@@ -958,27 +958,25 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
              limit++;
 
              evol = *evolution_of_loop;
-             res = follow_ssa_edge
-               (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
-
-             if (res == t_true)
-               *evolution_of_loop = add_to_evolution
+             evol = add_to_evolution
                  (loop->num,
                   chrec_convert (type, evol, at_stmt),
                   code, rhs1, at_stmt);
-
+             res = follow_ssa_edge
+               (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
+             if (res == t_true)
+               *evolution_of_loop = evol;
              else if (res == t_false)
                {
+                 *evolution_of_loop = add_to_evolution
+                     (loop->num,
+                      chrec_convert (type, *evolution_of_loop, at_stmt),
+                      code, rhs0, at_stmt);
                  res = follow_ssa_edge
                    (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
                     evolution_of_loop, limit);
-
                  if (res == t_true)
-                   *evolution_of_loop = add_to_evolution
-                     (loop->num,
-                      chrec_convert (type, *evolution_of_loop, at_stmt),
-                      code, rhs0, at_stmt);
-
+                   ;
                  else if (res == t_dont_know)
                    *evolution_of_loop = chrec_dont_know;
                }
@@ -991,15 +989,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
            {
              /* Match an assignment under the form:
                 "a = b + ...".  */
+             *evolution_of_loop = add_to_evolution
+                 (loop->num, chrec_convert (type, *evolution_of_loop,
+                                            at_stmt),
+                  code, rhs1, at_stmt);
              res = follow_ssa_edge
                (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                 evolution_of_loop, limit);
              if (res == t_true)
-               *evolution_of_loop = add_to_evolution
-                 (loop->num, chrec_convert (type, *evolution_of_loop,
-                                            at_stmt),
-                  code, rhs1, at_stmt);
-
+               ;       
              else if (res == t_dont_know)
                *evolution_of_loop = chrec_dont_know;
            }
@@ -1009,15 +1007,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
        {
          /* Match an assignment under the form:
             "a = ... + c".  */
+         *evolution_of_loop = add_to_evolution
+             (loop->num, chrec_convert (type, *evolution_of_loop,
+                                        at_stmt),
+              code, rhs0, at_stmt);
          res = follow_ssa_edge
            (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
             evolution_of_loop, limit);
          if (res == t_true)
-           *evolution_of_loop = add_to_evolution
-             (loop->num, chrec_convert (type, *evolution_of_loop,
-                                        at_stmt),
-              code, rhs0, at_stmt);
-
+           ;
          else if (res == t_dont_know)
            *evolution_of_loop = chrec_dont_know;
        }
@@ -1042,13 +1040,13 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
          if (TREE_CODE (rhs1) == SSA_NAME)
            limit++;
 
+         *evolution_of_loop = add_to_evolution
+             (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
+              MINUS_EXPR, rhs1, at_stmt);
          res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                                 evolution_of_loop, limit);
          if (res == t_true)
-           *evolution_of_loop = add_to_evolution
-             (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
-              MINUS_EXPR, rhs1, at_stmt);
-
+           ;
          else if (res == t_dont_know)
            *evolution_of_loop = chrec_dont_know;
        }