diff options
author | Richard Guenther <rguenther@suse.de> | 2010-08-12 10:38:05 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-08-12 10:38:05 +0000 |
commit | 2d698d3bb7f1b7761b35b31326a0326ce375ef8e (patch) | |
tree | 0b5ac0be840f1c9c145ded9acd7debd5de9e9e84 /gcc/tree-ssa-reassoc.c | |
parent | 1be38ccb1b4a2208403ffe980073d6ed2bb61490 (diff) | |
download | gcc-2d698d3bb7f1b7761b35b31326a0326ce375ef8e.zip gcc-2d698d3bb7f1b7761b35b31326a0326ce375ef8e.tar.gz gcc-2d698d3bb7f1b7761b35b31326a0326ce375ef8e.tar.bz2 |
re PR tree-optimization/45232 (tree reassociation introduces undefined overflow)
2010-08-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45232
* tree-ssa-reassoc.c (can_reassociate_p): Disable re-association
for types with undefined overflow.
(reassociate_bb): Allow re-associating of bit and min/max
operations for types with undefined overflow.
* tree-ssa-forwprop.c (associate_plusminus): New function.
(tree_ssa_forward_propagate_single_use_vars): Call it.
* gcc.dg/tree-ssa/pr44133.c: Adjust warning location.
* gcc.dg/tree-ssa/loop-7.c: Adjust.
* gcc.dg/tree-ssa/reassoc-1.c: XFAIL.
* gcc.dg/tree-ssa/reassoc-20.c: Add reassoc-1.c variant with
unsigned arithmetic.
* gcc.dg/tree-ssa/reassoc-14.c: Use unsigned arithmetic.
* gcc.dg/tree-ssa/reassoc-15.c: Likewise.
* gcc.dg/tree-ssa/reassoc-18.c: Likewise.
* gcc.dg/tree-ssa/reassoc-2.c: XFAIL.
* gcc.dg/tree-ssa/reassoc-21.c: Add reassoc-2.c variant with
unsigned arithmetic.
* gcc.dg/tree-ssa/reassoc-6.c: XFAIL.
* gcc.dg/tree-ssa/reassoc-22.c: Add reassoc-6.c variant with
unsigned arithmetic.
* gcc.dg/tree-ssa/reassoc-7.c: Use unsigned arithmetic.
* gcc.dg/tree-ssa/reassoc-9.c: XFAIL.
* gcc.dg/tree-ssa/reassoc-23.c: Add reassoc-9.c variant with
unsigned arithmetic.
* gcc.dg/tree-ssa/ssa-pre-2.c: Adjust.
* gcc.dg/tree-ssa/negate.c: Adjust.
* gcc.dg/vect/vect-1.c: Adjust.
* gfortran.dg/reassoc_6.f: XFAIL.
From-SVN: r163190
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 6cd3ceb..adc5a8d 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1949,7 +1949,7 @@ static bool can_reassociate_p (tree op) { tree type = TREE_TYPE (op); - if (INTEGRAL_TYPE_P (type) + if ((INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type)) || NON_SAT_FIXED_POINT_TYPE_P (type) || (flag_associative_math && FLOAT_TYPE_P (type))) return true; @@ -2065,9 +2065,16 @@ reassociate_bb (basic_block bb) rhs1 = gimple_assign_rhs1 (stmt); rhs2 = gimple_assign_rhs2 (stmt); - if (!can_reassociate_p (lhs) - || !can_reassociate_p (rhs1) - || !can_reassociate_p (rhs2)) + /* For non-bit or min/max operations we can't associate + all types. Verify that here. */ + if (rhs_code != BIT_IOR_EXPR + && rhs_code != BIT_AND_EXPR + && rhs_code != BIT_XOR_EXPR + && rhs_code != MIN_EXPR + && rhs_code != MAX_EXPR + && (!can_reassociate_p (lhs) + || !can_reassociate_p (rhs1) + || !can_reassociate_p (rhs2))) continue; if (associative_tree_code (rhs_code)) |