aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-10-18 10:26:06 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-10-18 10:26:06 +0200
commit8ddf04c2b02d457ee08a8158dab98ec2f3273d66 (patch)
treeb7acef529c889515ad15e65810919314e6d35650 /gcc/fold-const.c
parent1d32bbcdcb9839efa24655752ce90ce2ae97fa06 (diff)
downloadgcc-8ddf04c2b02d457ee08a8158dab98ec2f3273d66.zip
gcc-8ddf04c2b02d457ee08a8158dab98ec2f3273d66.tar.gz
gcc-8ddf04c2b02d457ee08a8158dab98ec2f3273d66.tar.bz2
re PR middle-end/46019 (x / (0x200000000ULL << y) miscompilation with 32-bit HWI)
PR middle-end/46019 * fold-const.c (fold_binary_loc): If integer_pow2p has TREE_INT_CST_LOW zero, look at TREE_INT_CST_HIGH. * gcc.c-torture/execute/pr46019.c: New test. From-SVN: r165610
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 8146920..808f491 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -11611,7 +11611,13 @@ fold_binary_loc (location_t loc,
if (integer_pow2p (sval) && tree_int_cst_sgn (sval) > 0)
{
tree sh_cnt = TREE_OPERAND (arg1, 1);
- unsigned long pow2 = exact_log2 (TREE_INT_CST_LOW (sval));
+ unsigned long pow2;
+
+ if (TREE_INT_CST_LOW (sval))
+ pow2 = exact_log2 (TREE_INT_CST_LOW (sval));
+ else
+ pow2 = exact_log2 (TREE_INT_CST_HIGH (sval))
+ + HOST_BITS_PER_WIDE_INT;
if (strict_overflow_p)
fold_overflow_warning (("assuming signed overflow does not "