2006-02-25 Roger Sayle <roger@eyesopen.com>
+ * simplify-rtx.c (simplify_relational_operation_1): Simplify
+ (X^Y) == 0 as X == Y and (X^Y) != 0 as X != Y. Simplify (X^Y) == Y
+ as X == 0, and some symmetry related transformations.
+ Simplify (X^C1) == C2 as X == (C1^C2). Split long comment line.
+
+2006-02-25 Roger Sayle <roger@eyesopen.com>
+
PR middle-end/23673
* fold-const.c (fold_binary) <EQ_EXPR>: Fold (X^Y) == 0 as X == Y
and (X^Y) != 0 as X != Y. Fold (X^Y) == Y as X == 0, and some
{
if (INTVAL (op1) == 0 && COMPARISON_P (op0))
{
- /* If op0 is a comparison, extract the comparison arguments form it. */
+ /* If op0 is a comparison, extract the comparison arguments
+ from it. */
if (code == NE)
{
if (GET_MODE (op0) == mode)
? simplify_gen_unary (ZERO_EXTEND, mode, op0, cmp_mode)
: lowpart_subreg (mode, op0, cmp_mode);
+ /* (eq/ne (xor x y) 0) simplifies to (eq/ne x y). */
+ if ((code == EQ || code == NE)
+ && op1 == const0_rtx
+ && op0code == XOR)
+ return simplify_gen_relational (code, mode, cmp_mode,
+ XEXP (op0, 0), XEXP (op0, 1));
+
+ /* (eq/ne (xor x y) x) simplifies to (eq/ne x 0). */
+ if ((code == EQ || code == NE)
+ && op0code == XOR
+ && rtx_equal_p (XEXP (op0, 0), op1)
+ && !side_effects_p (XEXP (op0, 1)))
+ return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx);
+ /* Likewise (eq/ne (xor x y) y) simplifies to (eq/ne y 0). */
+ if ((code == EQ || code == NE)
+ && op0code == XOR
+ && rtx_equal_p (XEXP (op0, 1), op1)
+ && !side_effects_p (XEXP (op0, 0)))
+ return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx);
+
+ /* (eq/ne (xor x C1) C2) simplifies to (eq/ne x (C1^C2)). */
+ if ((code == EQ || code == NE)
+ && op0code == XOR
+ && (GET_CODE (op1) == CONST_INT
+ || GET_CODE (op1) == CONST_DOUBLE)
+ && (GET_CODE (XEXP (op0, 1)) == CONST_INT
+ || GET_CODE (XEXP (op0, 1)) == CONST_DOUBLE))
+ return simplify_gen_relational (code, mode, cmp_mode, XEXP (op0, 0),
+ simplify_gen_binary (XOR, cmp_mode,
+ XEXP (op0, 1), op1));
+
return NULL_RTX;
}