re PR middle-end/36817 (internal compiler error: in compare_values_warnv)
authorRichard Guenther <rguenther@suse.de>
Thu, 21 Aug 2008 13:50:30 +0000 (13:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Aug 2008 13:50:30 +0000 (13:50 +0000)
2008-08-21  Richard Guenther  <rguenther@suse.de>

PR middle-end/36817
* tree-chrec.c (chrec_apply): Always call chrec_fold_plus which
makes sure to produce a result of the correct type.

* gcc.c-torture/compile/pr36817.c: New testcase.

From-SVN: r139385

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr36817.c [new file with mode: 0644]
gcc/tree-chrec.c

index d766455..e897d50 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-21  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36817
+       * tree-chrec.c (chrec_apply): Always call chrec_fold_plus which
+       makes sure to produce a result of the correct type.
+
 2008-08-21  Jan Hubicka  <jh@suse.cz>
        Backport from LTO branch:
 
index 9ca95d1..4cade5a 100644 (file)
@@ -1,5 +1,10 @@
 2008-08-21  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/36817
+       * gcc.c-torture/compile/pr36817.c: New testcase.
+
+2008-08-21  Richard Guenther  <rguenther@suse.de>
+
        * gcc.dg/tree-ssa/ssa-fre-13.c: Remove XFAIL.
        * gcc.dg/tree-ssa/ssa-fre-14.c: Likewise.
        * gcc.dg/tree-ssa/ssa-fre-17.c: Likewise.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr36817.c b/gcc/testsuite/gcc.c-torture/compile/pr36817.c
new file mode 100644 (file)
index 0000000..396f491
--- /dev/null
@@ -0,0 +1,10 @@
+void xxx()
+{
+  unsigned i;
+  unsigned *p=0;
+  for(i=0; i<4; ++i)
+    *p++=0;
+  for(i=0; i<4; ++i)
+    *p++=0;
+}
+
index 89e96fd..da35952 100644 (file)
@@ -579,8 +579,7 @@ chrec_apply (unsigned var,
       /* "{a, +, b} (x)"  ->  "a + b*x".  */
       x = chrec_convert_rhs (type, x, NULL);
       res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x);
-      if (!integer_zerop (CHREC_LEFT (chrec)))
-       res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
+      res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
     }
   
   else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)