aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-08-12 17:21:34 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-08-12 17:21:34 +0200
commita8c56818780786dd56e9656ddfa9806da4387e9c (patch)
tree639f56221290e502c4e4cfc6c62da003331396f5 /gcc/fold-const.c
parentd2be8071543ab02afcf36637d0f02da2d51e3f41 (diff)
downloadgcc-a8c56818780786dd56e9656ddfa9806da4387e9c.zip
gcc-a8c56818780786dd56e9656ddfa9806da4387e9c.tar.gz
gcc-a8c56818780786dd56e9656ddfa9806da4387e9c.tar.bz2
re PR middle-end/45262 (Optimization results in wrong result on expression x>>31||(-x)>>31)
PR middle-end/45262 * fold-const.c (make_range) <case NEGATE_EXPR>: Punt if -a overflows. Normalize the range. * gcc.c-torture/execute/pr45262.c: New test. From-SVN: r163193
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9ca5eff..d63411e 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3985,9 +3985,9 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh,
n_high = range_binop (MINUS_EXPR, exp_type,
build_int_cst (exp_type, 0),
0, low, 0);
- low = n_low, high = n_high;
- exp = arg0;
- continue;
+ if (n_high != 0 && TREE_OVERFLOW (n_high))
+ break;
+ goto normalize;
case BIT_NOT_EXPR:
/* ~ X -> -X - 1 */
@@ -4021,6 +4021,7 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh,
if (TYPE_OVERFLOW_UNDEFINED (arg0_type))
*strict_overflow_p = true;
+ normalize:
/* Check for an unsigned range which has wrapped around the maximum
value thus making n_high < n_low, and normalize it. */
if (n_low && n_high && tree_int_cst_lt (n_high, n_low))