diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-06-01 17:01:17 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-06-01 17:01:17 +0000 |
commit | 4efa926130748eacb2ab2773cfb16426baed95a2 (patch) | |
tree | e127bd3746dbcafe39b599443facbb089e438fe1 /gcc | |
parent | 3dfaf1d7dbe64f27aa61388f18971b53a923db9f (diff) | |
download | gcc-4efa926130748eacb2ab2773cfb16426baed95a2.zip gcc-4efa926130748eacb2ab2773cfb16426baed95a2.tar.gz gcc-4efa926130748eacb2ab2773cfb16426baed95a2.tar.bz2 |
re PR tree-optimization/53501 (scev introduces signed overflow)
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/restrict-2.c | 2 |
4 files changed, 28 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b80223..ca4f147 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 64a0d7f..5ea5110 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27dbddc..76e4e6b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/c-c++-common/restrict-2.c b/gcc/testsuite/c-c++-common/restrict-2.c index 42ed398..3f71b77 100644 --- a/gcc/testsuite/c-c++-common/restrict-2.c +++ b/gcc/testsuite/c-c++-common/restrict-2.c @@ -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" } } */ |