diff options
author | Richard Guenther <rguenther@suse.de> | 2009-04-01 13:59:53 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-04-01 13:59:53 +0000 |
commit | 299b87f8a21c1ae2611434529c8c4dfc4c291d95 (patch) | |
tree | 68e3daf36617195cce79f5f8595598552dae258e /gcc/fold-const.c | |
parent | b85eb797e2ffda39def175285b334b721c0b2b4f (diff) | |
download | gcc-299b87f8a21c1ae2611434529c8c4dfc4c291d95.zip gcc-299b87f8a21c1ae2611434529c8c4dfc4c291d95.tar.gz gcc-299b87f8a21c1ae2611434529c8c4dfc4c291d95.tar.bz2 |
fold-const.c (fold_plusminus_mult_expr): Do not fold i * 4 + 2 to (i * 2 + 1) * 2.
2009-04-01 Richard Guenther <rguenther@suse.de>
* fold-const.c (fold_plusminus_mult_expr): Do not fold
i * 4 + 2 to (i * 2 + 1) * 2.
* gcc.dg/fold-plusmult-2.c: New testcase.
From-SVN: r145403
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ec06954..9c1a463 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7466,7 +7466,11 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1) else maybe_same = arg11; - if (exact_log2 (abs (int11)) > 0 && int01 % int11 == 0) + if (exact_log2 (abs (int11)) > 0 && int01 % int11 == 0 + /* The remainder should not be a constant, otherwise we + end up folding i * 4 + 2 to (i * 2 + 1) * 2 which has + increased the number of multiplications necessary. */ + && TREE_CODE (arg10) != INTEGER_CST) { alt0 = fold_build2 (MULT_EXPR, TREE_TYPE (arg00), arg00, build_int_cst (TREE_TYPE (arg00), |