re PR tree-optimization/53501 (scev introduces signed overflow)
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 1 Jun 2012 17:01:17 +0000 (17:01 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 1 Jun 2012 17:01:17 +0000 (17:01 +0000)
PR middle-end/53501
* fold-const.c (fold_binary_loc): Refine previous change.
testsuite/
* c-c++-common/restrict-2.c: Revert previous change.

From-SVN: r188118

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/restrict-2.c

index 4b802230f3f69709de613af5d92f56ee3d8e99f0..ca4f1473aa7a89a487b3b8940e69a983ac777439 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR middle-end/53501
+       * fold-const.c (fold_binary_loc): Refine previous change.
+
 2012-06-01  Olivier Hainque  <hainque@adacore.com>
 
        * config/rs6000/vxworks.h (SUBSUBTARGET_OVERRIDE_OPTIONS): Restore
index 64a0d7fd29ad84c311b933ee4d001debf78b6e83..5ea5110a72b65e81504ee441fa3727807c12851f 100644 (file)
@@ -10042,15 +10042,18 @@ 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 (op0) == MULT_EXPR
-          || TREE_CODE (op1) == MULT_EXPR)
+      /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the same or
+        one.  Make sure the type is not saturating and has the signedness of
+        the stripped operands, as fold_plusminus_mult_expr will re-associate.
+        ??? The latter condition should use TYPE_OVERFLOW_* flags instead.  */
+      if ((TREE_CODE (arg0) == MULT_EXPR
+          || TREE_CODE (arg1) == MULT_EXPR)
          && !TYPE_SATURATING (type)
+         && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg0))
+         && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg1))
          && (!FLOAT_TYPE_P (type) || flag_associative_math))
         {
-         tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1);
+         tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1);
          if (tem)
            return tem;
        }
@@ -10665,15 +10668,18 @@ fold_binary_loc (location_t loc,
          && (tem = distribute_real_division (loc, code, type, arg0, arg1)))
        return tem;
 
-      /* 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 (op0) == MULT_EXPR
-          || TREE_CODE (op1) == MULT_EXPR)
+      /* Handle (A1 * C1) - (A2 * C2) with A1, A2 or C1, C2 being the same or
+        one.  Make sure the type is not saturating and has the signedness of
+        the stripped operands, as fold_plusminus_mult_expr will re-associate.
+        ??? The latter condition should use TYPE_OVERFLOW_* flags instead.  */
+      if ((TREE_CODE (arg0) == MULT_EXPR
+          || TREE_CODE (arg1) == MULT_EXPR)
          && !TYPE_SATURATING (type)
+         && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg0))
+         && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (arg1))
          && (!FLOAT_TYPE_P (type) || flag_associative_math))
         {
-         tree tem = fold_plusminus_mult_expr (loc, code, type, op0, op1);
+         tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1);
          if (tem)
            return tem;
        }
index 27dbddca0d4f07668394614ea0eccf341ad568f2..76e4e6b0fe853fee7485f5079f7f004850495448 100644 (file)
@@ -1,3 +1,7 @@
+2012-06-01  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-c++-common/restrict-2.c: Revert previous change.
+
 2012-06-01  Jason Merrill  <jason@redhat.com>
 
        PR c++/53137
index 42ed398f67085a8192683d2e5f1662c9f0e328b5..3f71b77b9ced926cd94892f8d8bd7d5eba0f58bd 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" 10 "lim1" } } */
+/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim1" } } */
 /* { dg-final { cleanup-tree-dump "lim1" } } */