aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-01-26 10:30:36 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-01-26 10:30:36 +0000
commit5b55e6e333c97aaefc1db6c9d8411de578d05614 (patch)
tree21db3fe6e8247b8085351073439c65bef3bda73c /gcc/fold-const.c
parentaf2e3244f56152d94a18c1339a18a4c0b0e33060 (diff)
downloadgcc-5b55e6e333c97aaefc1db6c9d8411de578d05614.zip
gcc-5b55e6e333c97aaefc1db6c9d8411de578d05614.tar.gz
gcc-5b55e6e333c97aaefc1db6c9d8411de578d05614.tar.bz2
re PR tree-optimization/81082 (Failure to vectorise after reassociating index computation)
2018-01-26 Richard Biener <rguenther@suse.de> PR tree-optimization/81082 * fold-const.c (fold_plusminus_mult_expr): Do not perform the association if it requires casting to unsigned. * match.pd ((A * C) +- (B * C) -> (A+-B)): New patterns derived from fold_plusminus_mult_expr to catch important cases late when range info is available. * gcc.dg/vect/pr81082.c: New testcase. * gcc.dg/tree-ssa/loop-15.c: XFAIL the (int)((unsigned)n + -1U) * n + n simplification to n * n. From-SVN: r257077
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 744c355..c86c3f9 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7097,7 +7097,7 @@ fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type,
/* Same may be zero and thus the operation 'code' may overflow. Likewise
same may be minus one and thus the multiplication may overflow. Perform
- the operations in an unsigned type. */
+ the sum operation in an unsigned type. */
tree utype = unsigned_type_for (type);
tree tem = fold_build2_loc (loc, code, utype,
fold_convert_loc (loc, utype, alt0),
@@ -7110,9 +7110,9 @@ fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type,
return fold_build2_loc (loc, MULT_EXPR, type,
fold_convert (type, tem), same);
- return fold_convert_loc (loc, type,
- fold_build2_loc (loc, MULT_EXPR, utype, tem,
- fold_convert_loc (loc, utype, same)));
+ /* Do not resort to unsigned multiplication because
+ we lose the no-overflow property of the expression. */
+ return NULL_TREE;
}
/* Subroutine of native_encode_expr. Encode the INTEGER_CST