diff options
author | Richard Guenther <rguenther@suse.de> | 2008-04-29 13:52:53 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-04-29 13:52:53 +0000 |
commit | 81ad578ea1b8fbeafe172152cc27c0f4911502ce (patch) | |
tree | 5652cba588dcd682df8033c5a5aaac5927d6ce38 /gcc/fold-const.c | |
parent | a170f0affe9a70cbe4e156a4323c03ac76024422 (diff) | |
download | gcc-81ad578ea1b8fbeafe172152cc27c0f4911502ce.zip gcc-81ad578ea1b8fbeafe172152cc27c0f4911502ce.tar.gz gcc-81ad578ea1b8fbeafe172152cc27c0f4911502ce.tar.bz2 |
re PR middle-end/36077 (Expressions result is wrong)
2008-04-29 Richard Guenther <rguenther@suse.de>
PR middle-end/36077
* fold-const.c (extract_muldiv_1): In combining division constants
make sure to never overflow.
* gcc.c-torture/execute/pr36077.c: New testcase.
From-SVN: r134792
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a4d5760..aae2037 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5953,8 +5953,13 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, /* If these are the same operation types, we can associate them assuming no overflow. */ if (tcode == code - && 0 != (t1 = const_binop (MULT_EXPR, fold_convert (ctype, op1), - fold_convert (ctype, c), 0)) + && 0 != (t1 = int_const_binop (MULT_EXPR, fold_convert (ctype, op1), + fold_convert (ctype, c), 1)) + && 0 != (t1 = force_fit_type_double (ctype, TREE_INT_CST_LOW (t1), + TREE_INT_CST_HIGH (t1), + (TYPE_UNSIGNED (ctype) + && tcode != MULT_EXPR) ? -1 : 1, + TREE_OVERFLOW (t1))) && !TREE_OVERFLOW (t1)) return fold_build2 (tcode, ctype, fold_convert (ctype, op0), t1); |