]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/53501 (scev introduces signed overflow)
authorRichard Guenther <rguenther@suse.de>
Wed, 30 May 2012 12:29:26 +0000 (12:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 30 May 2012 12:29:26 +0000 (12:29 +0000)
2012-05-30  Richard Guenther  <rguenther@suse.de>

PR middle-end/53501
* fold-const.c (fold_binary_loc): Make sure to call
fold_plusminus_mult_expr with the original sign of operands.

* gcc.dg/torture/pr53501.c: New testcase.
* c-c++-common/restrict-2.c: Adjust.

From-SVN: r188009

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/restrict-2.c
gcc/testsuite/gcc.dg/torture/pr53501.c [new file with mode: 0644]

index d38383f7f0e74eb1c99d881f895dbe077d8c9cef..df7d3e8692073b53a211f4abb84c5a2e18b57a88 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-30  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53501
+       * fold-const.c (fold_binary_loc): Make sure to call
+       fold_plusminus_mult_expr with the original sign of operands.
+
 2012-05-30  Steven Bosscher  <steven@gcc.gnu.org>
 
        * Makefile.in: Fix many dependencies.
index 8a548107485846d8ec3d989e5e0acd17e737a105..64a0d7fd29ad84c311b933ee4d001debf78b6e83 100644 (file)
@@ -10045,12 +10045,12 @@ fold_binary_loc (location_t loc,
       /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the
         same or one.  Make sure type is not saturating.
         fold_plusminus_mult_expr will re-associate.  */
-      if ((TREE_CODE (arg0) == MULT_EXPR
-          || TREE_CODE (arg1) == MULT_EXPR)
+      if ((TREE_CODE (op0) == MULT_EXPR
+          || TREE_CODE (op1) == MULT_EXPR)
          && !TYPE_SATURATING (type)
          && (!FLOAT_TYPE_P (type) || flag_associative_math))
         {
-         tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1);
+         tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1);
          if (tem)
            return tem;
        }
@@ -10668,12 +10668,12 @@ fold_binary_loc (location_t loc,
       /* Handle (A1 * C1) - (A2 * C2) with A1, A2 or C1, C2 being the
         same or one.  Make sure type is not saturating.
         fold_plusminus_mult_expr will re-associate.  */
-      if ((TREE_CODE (arg0) == MULT_EXPR
-          || TREE_CODE (arg1) == MULT_EXPR)
+      if ((TREE_CODE (op0) == MULT_EXPR
+          || TREE_CODE (op1) == MULT_EXPR)
          && !TYPE_SATURATING (type)
          && (!FLOAT_TYPE_P (type) || flag_associative_math))
         {
-         tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1);
+         tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1);
          if (tem)
            return tem;
        }
index 4e53d2f32c4ab450c7eb33c49831727df321e17e..49d88e728b5630a66b8dc8637939414074ea6d9a 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-30  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53501
+       * gcc.dg/torture/pr53501.c: New testcase.
+       * c-c++-common/restrict-2.c: Adjust.
+
 2012-05-30  Alan Modra  <amodra@gmail.com>
 
        * gcc.target/powerpc/powerpc.exp: Load torture-options.exp, call
index 3f71b77b9ced926cd94892f8d8bd7d5eba0f58bd..42ed398f67085a8192683d2e5f1662c9f0e328b5 100644 (file)
@@ -10,5 +10,5 @@ void foo (float * __restrict__ a, float * __restrict__ b, int n, int j)
 
 /* We should move the RHS of the store out of the loop.  */
 
-/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim1" } } */
+/* { dg-final { scan-tree-dump-times "Moving statement" 10 "lim1" } } */
 /* { dg-final { cleanup-tree-dump "lim1" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr53501.c b/gcc/testsuite/gcc.dg/torture/pr53501.c
new file mode 100644 (file)
index 0000000..36e3ae6
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int e[100], n, here;
+
+void __attribute__((noinline))
+foo(void)
+{
+  int i, k = 0;
+  for (i = 0; i < n; ++i) { e[k] = 10; ++k; e[k] = 10; ++k; }
+  for (i = 0; i < k; ++i) here = 1;
+  if (here != 1)
+    abort ();
+}
+
+int main(void)
+{
+  n = 10;
+  foo();
+  return 0;
+}
This page took 0.127398 seconds and 5 git commands to generate.