diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1996-10-30 16:16:41 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1996-10-30 16:16:41 -0500 |
commit | 27bae8e5719a3412dedd8ae44d285efa37c40ddf (patch) | |
tree | 4c50ea48cafd0be5ad4beca669ac885dbd6fe1db /gcc/fold-const.c | |
parent | 505d6e2b92aedbbe10a95fbbbe4e07b0d9d47fb0 (diff) | |
download | gcc-27bae8e5719a3412dedd8ae44d285efa37c40ddf.zip gcc-27bae8e5719a3412dedd8ae44d285efa37c40ddf.tar.gz gcc-27bae8e5719a3412dedd8ae44d285efa37c40ddf.tar.bz2 |
(range_binop): Strip NOPs from result and verify it's an INTEGER_CST.
(make_range, case BIT_NOT_EXPR): Fix typo in constant for PLUS_EXPR.
From-SVN: r13079
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ddd2f63..9e75466 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2647,6 +2647,7 @@ range_binop (code, type, arg0, upper0_p, arg1, upper1_p) tree arg0, arg1; int upper0_p, upper1_p; { + tree tem; int result; int sgn0, sgn1; @@ -2656,8 +2657,12 @@ range_binop (code, type, arg0, upper0_p, arg1, upper1_p) are handled for consistency. */ if (arg0 != 0 && arg1 != 0) - return fold (build (code, type != 0 ? type : TREE_TYPE (arg0), - arg0, convert (TREE_TYPE (arg0), arg1))); + { + tem = fold (build (code, type != 0 ? type : TREE_TYPE (arg0), + arg0, convert (TREE_TYPE (arg0), arg1))); + STRIP_NOPS (tem); + return TREE_CODE (tem) == INTEGER_CST ? tem : 0; + } if (TREE_CODE_CLASS (code) != '<') return 0; @@ -2790,7 +2795,7 @@ make_range (exp, pin_p, plow, phigh) case BIT_NOT_EXPR: /* ~ X -> -X - 1 */ exp = build (MINUS_EXPR, type, build1 (NEGATE_EXPR, type, arg0), - convert (type, integer_zero_node)); + convert (type, integer_one_node)); continue; case PLUS_EXPR: case MINUS_EXPR: @@ -2809,15 +2814,13 @@ make_range (exp, pin_p, plow, phigh) || (n_high != 0 && TREE_OVERFLOW (n_high))) break; - /* Check for an unsigned range which has wrapped around the maximum - value thus making n_high < n_low, and normalize it. */ + /* Check for a range which has wrapped around the maximum value + thus making n_high < n_low. Normalize any such range it. */ if (n_low && n_high && tree_int_cst_lt (n_high, n_low)) - { - low = n_high, high = n_low; - in_p = ! in_p; - } + low = n_high, high = n_low, in_p = ! in_p; else low = n_low, high = n_high; + exp = arg0; continue; |