diff options
author | Alan Modra <amodra@bigpond.net.au> | 2002-01-22 23:42:07 +0000 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2002-01-23 10:12:07 +1030 |
commit | d0c9db30790251ccb1e4af3848aceb41ead63d71 (patch) | |
tree | f8312a49809cfe096c794e2e9c08fe11a35c9aa4 /gcc/combine.c | |
parent | 1e7e480e5c37ab841a7ddcc48f5b8614a3b55096 (diff) | |
download | gcc-d0c9db30790251ccb1e4af3848aceb41ead63d71.zip gcc-d0c9db30790251ccb1e4af3848aceb41ead63d71.tar.gz gcc-d0c9db30790251ccb1e4af3848aceb41ead63d71.tar.bz2 |
combine.c (simplify_and_const_int): Don't trunc_int_for_mode "nonzero" as that might add "1" bits.
* combine.c (simplify_and_const_int): Don't trunc_int_for_mode
"nonzero" as that might add "1" bits. Ensure "constop" is
properly sign extened.
(force_to_mode): Tweak for sign extended constop.
From-SVN: r49112
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index 663fd1d..47ac3a8 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6701,7 +6701,8 @@ force_to_mode (x, mode, mask, reg, just_select) need it. */ if (GET_CODE (x) == AND && GET_CODE (XEXP (x, 1)) == CONST_INT - && (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) == mask) + && ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x))) + == (HOST_WIDE_INT) mask)) x = XEXP (x, 0); /* If it remains an AND, try making another AND with the bits @@ -7755,7 +7756,6 @@ simplify_and_const_int (x, mode, varop, constop) MODE. */ nonzero = nonzero_bits (varop, mode) & GET_MODE_MASK (mode); - nonzero = trunc_int_for_mode (nonzero, mode); /* Turn off all bits in the constant that are known to already be zero. Thus, if the AND isn't needed at all, we will have CONSTOP == NONZERO_BITS @@ -7823,19 +7823,22 @@ simplify_and_const_int (x, mode, varop, constop) /* If we are only masking insignificant bits, return VAROP. */ if (constop == nonzero) x = varop; - - /* Otherwise, return an AND. See how much, if any, of X we can use. */ - else if (x == 0 || GET_CODE (x) != AND || GET_MODE (x) != mode) - x = gen_binary (AND, mode, varop, GEN_INT (constop)); - else { + /* Otherwise, return an AND. */ constop = trunc_int_for_mode (constop, mode); - if (GET_CODE (XEXP (x, 1)) != CONST_INT - || (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) != constop) - SUBST (XEXP (x, 1), GEN_INT (constop)); + /* See how much, if any, of X we can use. */ + if (x == 0 || GET_CODE (x) != AND || GET_MODE (x) != mode) + x = gen_binary (AND, mode, varop, GEN_INT (constop)); - SUBST (XEXP (x, 0), varop); + else + { + if (GET_CODE (XEXP (x, 1)) != CONST_INT + || (unsigned HOST_WIDE_INT) INTVAL (XEXP (x, 1)) != constop) + SUBST (XEXP (x, 1), GEN_INT (constop)); + + SUBST (XEXP (x, 0), varop); + } } return x; |