re PR tree-optimization/28230 (-O2 -fwrapv miscompiles gcc, binutils, gzip.)
authorRichard Guenther <rguenther@suse.de>
Wed, 11 Oct 2006 16:05:37 +0000 (16:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 11 Oct 2006 16:05:37 +0000 (16:05 +0000)
2006-10-11  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/28230
* tree-vrp.c (vrp_int_const_binop): Move flag_wrapv handling
to the correct place.

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

From-SVN: r117637

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr28230.c [new file with mode: 0644]
gcc/tree-vrp.c

index 8eca2504987857201901bcd4eb92bfd814815a9d..6fd39c76efdf61131c552c14b6c7c6172fa8ccdd 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-11  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/28230
+       * tree-vrp.c (vrp_int_const_binop): Move flag_wrapv handling
+       to the correct place.
+
 2006-10-11  Richard Guenther  <rguenther@suse.de>
 
        PR inline-asm/29119
index c9b7c54fd6d25a2af766988b5b51efae9c828fca..aa9cd9ec1345dbd96fc3ee33e98640c1773edb53 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-11  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/28230
+       * gcc.dg/torture/pr28230.c: New testcase.
+
 2006-10-11  Richard Guenther  <rguenther@suse.de>
 
        PR inline-asm/29119
diff --git a/gcc/testsuite/gcc.dg/torture/pr28230.c b/gcc/testsuite/gcc.dg/torture/pr28230.c
new file mode 100644 (file)
index 0000000..5ecc0c7
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-fwrapv" } */
+
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w );
+void foo( unsigned long long bb, unsigned short tn, unsigned e, unsigned* w )
+{
+        unsigned n = tn + bb;
+        do {
+                e = (e > n) ? e : *w;
+                n -= (e > n) ? n : e;
+                if (*w)
+                        *w = 0;
+        } while ( n );
+}
+int main()
+{
+        unsigned w = 0;
+        foo( 0, 0, 0, &w );
+        return 0;
+}
index a2127446a85263f6c3b2b1deaeeeda3ed89ba965..4a30e4ee8a553670d264e40a738add32efbdcd86 100644 (file)
@@ -1235,14 +1235,12 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
 {
   tree res;
 
-  if (flag_wrapv)
-    return int_const_binop (code, val1, val2, 0);
+  res = int_const_binop (code, val1, val2, 0);
 
   /* If we are not using wrapping arithmetic, operate symbolically
      on -INF and +INF.  */
-  res = int_const_binop (code, val1, val2, 0);
-
-  if (TYPE_UNSIGNED (TREE_TYPE (val1)))
+  if (TYPE_UNSIGNED (TREE_TYPE (val1))
+      || flag_wrapv)
     {
       int checkz = compare_values (res, val1);
       bool overflow = false;