diff options
author | Bernd Schmidt <bernd.schmidt@analog.com> | 2009-04-24 16:19:36 +0000 |
---|---|---|
committer | Bernd Schmidt <bernds@gcc.gnu.org> | 2009-04-24 16:19:36 +0000 |
commit | f5a17c436deba380996b185e17c80e6063917670 (patch) | |
tree | b034cf35f9cf26b923ad93cd826a4344a685366e /gcc/simplify-rtx.c | |
parent | c91f9cd48c872994b2e8bedbd2e27c488a75bacb (diff) | |
download | gcc-f5a17c436deba380996b185e17c80e6063917670.zip gcc-f5a17c436deba380996b185e17c80e6063917670.tar.gz gcc-f5a17c436deba380996b185e17c80e6063917670.tar.bz2 |
simplify-rtx.c (simplify_binary_operation_1, case AND): Result is zero if no overlap in nonzero bits between the operands.
* simplify-rtx.c (simplify_binary_operation_1, case AND): Result is
zero if no overlap in nonzero bits between the operands.
From-SVN: r146738
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index b8b6ad8..e2b1673 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2304,17 +2304,22 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, case AND: if (trueop1 == CONST0_RTX (mode) && ! side_effects_p (op0)) return trueop1; - if (GET_CODE (trueop1) == CONST_INT - && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) + if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) { HOST_WIDE_INT nzop0 = nonzero_bits (trueop0, mode); - HOST_WIDE_INT val1 = INTVAL (trueop1); - /* If we are turning off bits already known off in OP0, we need - not do an AND. */ - if ((nzop0 & ~val1) == 0) - return op0; + HOST_WIDE_INT nzop1; + if (GET_CODE (trueop1) == CONST_INT) + { + HOST_WIDE_INT val1 = INTVAL (trueop1); + /* If we are turning off bits already known off in OP0, we need + not do an AND. */ + if ((nzop0 & ~val1) == 0) + return op0; + } + nzop1 = nonzero_bits (trueop1, mode); /* If we are clearing all the nonzero bits, the result is zero. */ - if ((val1 & nzop0) == 0 && !side_effects_p (op0)) + if ((nzop1 & nzop0) == 0 + && !side_effects_p (op0) && !side_effects_p (op1)) return CONST0_RTX (mode); } if (rtx_equal_p (trueop0, trueop1) && ! side_effects_p (op0) |