]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/36691 (wrong value left in induction variable)
authorRichard Guenther <rguenther@suse.de>
Mon, 4 Aug 2008 18:29:08 +0000 (18:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Aug 2008 18:29:08 +0000 (18:29 +0000)
2008-08-04  Richard Guenther  <rguenther@suse.de>

PR middle-end/36691
* tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne): Correctly
check for no_overflow.

* gcc.c-torture/execute/pr36691.c: New testcase.

From-SVN: r138645

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr36691.c [new file with mode: 0644]
gcc/tree-ssa-loop-niter.c

index 80b26c51ca9cbba345b16632c43e4caa40cc8064..224764ef985ead6866094c1ba3cf87a03b147b31 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36691
+       * tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne): Correctly
+       check for no_overflow.
+
 2008-08-04  Richard Guenther  <rguenther@suse.de>
 
        * tree-vect-transform.c (vectorizable_call): Fix tuplification.
index 2dafc220ec1817a08ba3a71b7bf64185e7373259..0041134e91b437125c20c7be3147477af963c975 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36691
+       * gcc.c-torture/execute/pr36691.c: New testcase.
+
 2008-08-04  Victor Kaplansky  <victork@il.ibm.com>
 
        * gcc.dg/vect/vect-complex-5.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr36691.c b/gcc/testsuite/gcc.c-torture/execute/pr36691.c
new file mode 100644 (file)
index 0000000..81fe6fd
--- /dev/null
@@ -0,0 +1,17 @@
+unsigned char g_5;
+
+void func_1 (void)
+{
+  for (g_5 = 9; g_5 >= 4; g_5 -= 5)
+    ;
+}
+
+extern void abort (void);
+int main (void)
+{
+  func_1 ();
+  if (g_5 != 0)
+    abort ();
+  return 0;
+}
+
index 83baae7828aafd4ec54b51901a69645c97823c55..1d0605e68b506cbac662b062b7c6c78528db909e 100644 (file)
@@ -697,7 +697,7 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1,
       /* The final value of the iv is iv1->base + MOD, assuming that this
         computation does not overflow, and that
         iv0->base <= iv1->base + MOD.  */
-      if (!iv1->no_overflow && !integer_zerop (mod))
+      if (!iv0->no_overflow && !integer_zerop (mod))
        {
          bound = fold_build2 (MINUS_EXPR, type,
                               TYPE_MAX_VALUE (type1), tmod);
@@ -719,7 +719,7 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1,
       /* The final value of the iv is iv0->base - MOD, assuming that this
         computation does not overflow, and that
         iv0->base - MOD <= iv1->base. */
-      if (!iv0->no_overflow && !integer_zerop (mod))
+      if (!iv1->no_overflow && !integer_zerop (mod))
        {
          bound = fold_build2 (PLUS_EXPR, type1,
                               TYPE_MIN_VALUE (type1), tmod);