diff options
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 34 |
2 files changed, 40 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2abdce..526af5d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 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 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 8b1f6fd..e84beda 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3512,7 +3512,8 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode, { 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) @@ -3561,6 +3562,37 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode 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; } |