re PR tree-optimization/45122 (-funsafe-loop-optimizations causes FAIL: gcc.c-torture...
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 3 Feb 2011 06:01:40 +0000 (06:01 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 3 Feb 2011 06:01:40 +0000 (06:01 +0000)
gcc/ChangeLog:
PR tree-optimization/45122
* tree-ssa-loop-niter.c (number_of_iterations_exit): Don't make
unsafe assumptions when there's more than one loop exit.
gcc/testsuite/ChangeLog:
PR tree-optimization/45122
* gcc.dg/tree-ssa/pr45122.c: New.

From-SVN: r169781

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr45122.c [new file with mode: 0644]
gcc/tree-ssa-loop-niter.c

index 1f16f47ea8dacb41b5047c1c5d5688ab50e82fd6..de9d846b7d353857b69fd2ddb679ebf0e416bb86 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-03  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR tree-optimization/45122
+       * tree-ssa-loop-niter.c (number_of_iterations_exit): Don't make
+       unsafe assumptions when there's more than one loop exit.
+
 2011-02-02  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/47272
index de8cec7888832adccd33f859a6424d4b75c71c30..69da9d62bd8e751c3f20d72bfbb88fb70245edc2 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-03  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR tree-optimization/45122
+       * gcc.dg/tree-ssa/pr45122.c: New.
+
 2011-02-02  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/47272
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr45122.c b/gcc/testsuite/gcc.dg/tree-ssa/pr45122.c
new file mode 100644 (file)
index 0000000..e979b76
--- /dev/null
@@ -0,0 +1,50 @@
+/* PR tree-optimization/27285 */
+/* PR tree-optimization/45122 */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -funsafe-loop-optimizations" } */
+
+extern void abort (void);
+
+struct S { unsigned char a, b, c, d[16]; };
+
+void __attribute__ ((noinline))
+foo (struct S *x, struct S *y)
+{
+  int a, b;
+  unsigned char c, *d, *e;
+
+  b = x->b;
+  d = x->d;
+  e = y->d;
+  a = 0;
+  while (b)
+    {
+      if (b >= 8)
+       {
+         c = 0xff;
+         b -= 8;
+       }
+      else
+       {
+         c = 0xff << (8 - b);
+         b = 0;
+       }
+
+      e[a] = d[a] & c;
+      a++;
+    }
+}
+
+int
+main (void)
+{
+  struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};
+  struct S y = { 0, 0, 0, { 0 }};
+
+  foo (&x, &y);
+  if (x.d[0] != y.d[0] || x.d[1] != y.d[1]
+      || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])
+    abort ();
+   return 0;
+}
index ee85f6fe00631f619ab8c7d38619a072a654f55d..c14e13c7248b5ada735c478820df4e5197e5b76d 100644 (file)
@@ -1890,7 +1890,7 @@ number_of_iterations_exit (struct loop *loop, edge exit,
   /* With -funsafe-loop-optimizations we assume that nothing bad can happen.
      But if we can prove that there is overflow or some other source of weird
      behavior, ignore the loop even with -funsafe-loop-optimizations.  */
-  if (integer_zerop (niter->assumptions))
+  if (integer_zerop (niter->assumptions) || !single_exit (loop))
     return false;
 
   if (flag_unsafe_loop_optimizations)