aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-03-22 13:23:00 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-03-22 13:23:00 +0000
commit9a10956c4bbf9fd7ff35cc87cea14e6cb6b3812c (patch)
tree4622382e583a127b4ebc7b3e6034749c6bb154d0 /gcc/fold-const.c
parent380d99c9aacfb3e4c1b23a0dee93110fe6a47e24 (diff)
downloadgcc-9a10956c4bbf9fd7ff35cc87cea14e6cb6b3812c.zip
gcc-9a10956c4bbf9fd7ff35cc87cea14e6cb6b3812c.tar.gz
gcc-9a10956c4bbf9fd7ff35cc87cea14e6cb6b3812c.tar.bz2
re PR target/70333 (Test miscompiled with -O0.)
2016-03-22 Richard Biener <rguenther@suse.de> PR middle-end/70333 * fold-const.c (extract_muldiv_1): Properly perform multiplication in the wide type. * gcc.dg/torture/pr70333.c: New testcase. From-SVN: r234401
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 696b4a6..9d861c6 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6376,18 +6376,17 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
bool overflow_p = false;
bool overflow_mul_p;
signop sign = TYPE_SIGN (ctype);
- wide_int mul = wi::mul (op1, c, sign, &overflow_mul_p);
+ unsigned prec = TYPE_PRECISION (ctype);
+ wide_int mul = wi::mul (wide_int::from (op1, prec, sign),
+ wide_int::from (c, prec, sign),
+ sign, &overflow_mul_p);
overflow_p = TREE_OVERFLOW (c) | TREE_OVERFLOW (op1);
if (overflow_mul_p
&& ((sign == UNSIGNED && tcode != MULT_EXPR) || sign == SIGNED))
overflow_p = true;
if (!overflow_p)
- {
- mul = wide_int::from (mul, TYPE_PRECISION (ctype),
- TYPE_SIGN (TREE_TYPE (op1)));
- return fold_build2 (tcode, ctype, fold_convert (ctype, op0),
- wide_int_to_tree (ctype, mul));
- }
+ return fold_build2 (tcode, ctype, fold_convert (ctype, op0),
+ wide_int_to_tree (ctype, mul));
}
/* If these operations "cancel" each other, we have the main