Commit f5a17c43 by Bernd Schmidt Committed by Bernd Schmidt

simplify-rtx.c (simplify_binary_operation_1, case AND): Result is zero if no…

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
parent c91f9cd4
2009-04-24 Bernd Schmidt <bernd.schmidt@analog.com>
* 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 <iant@google.com> 2009-04-24 Ian Lance Taylor <iant@google.com>
* combine.c (record_value_for_reg): Change 0 to VOIDmode, twice. * combine.c (record_value_for_reg): Change 0 to VOIDmode, twice.
......
...@@ -2304,17 +2304,22 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, ...@@ -2304,17 +2304,22 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
case AND: case AND:
if (trueop1 == CONST0_RTX (mode) && ! side_effects_p (op0)) if (trueop1 == CONST0_RTX (mode) && ! side_effects_p (op0))
return trueop1; return trueop1;
if (GET_CODE (trueop1) == CONST_INT if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
&& GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
{ {
HOST_WIDE_INT nzop0 = nonzero_bits (trueop0, mode); HOST_WIDE_INT nzop0 = nonzero_bits (trueop0, mode);
HOST_WIDE_INT val1 = INTVAL (trueop1); HOST_WIDE_INT nzop1;
/* If we are turning off bits already known off in OP0, we need if (GET_CODE (trueop1) == CONST_INT)
not do an AND. */ {
if ((nzop0 & ~val1) == 0) HOST_WIDE_INT val1 = INTVAL (trueop1);
return op0; /* 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 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); return CONST0_RTX (mode);
} }
if (rtx_equal_p (trueop0, trueop1) && ! side_effects_p (op0) if (rtx_equal_p (trueop0, trueop1) && ! side_effects_p (op0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment