From: bernds Date: Fri, 24 Apr 2009 16:19:36 +0000 (+0000) Subject: * simplify-rtx.c (simplify_binary_operation_1, case AND): Result is X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c79d4a4d3a67c8ed7b97ef4ba1f5d1ea6dfae76c;p=thirdparty%2Fgcc.git * simplify-rtx.c (simplify_binary_operation_1, case AND): Result is zero if no overlap in nonzero bits between the operands. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146738 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b0ed4ff7f14b..a48db46dcd5d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-04-24 Bernd Schmidt + + * simplify-rtx.c (simplify_binary_operation_1, case AND): Result is + zero if no overlap in nonzero bits between the operands. + 2009-04-24 Ian Lance Taylor * combine.c (record_value_for_reg): Change 0 to VOIDmode, twice. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index b8b6ad81763a..e2b1673a8dd2 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)