diff options
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index e7273a4fdb4..6cb5a6e5d24 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -5051,34 +5051,38 @@ simplify_relational_operation_1 (enum rtx_code code, machine_mode mode, simplify_gen_binary (XOR, cmp_mode, XEXP (op0, 1), op1)); - /* (eq/ne (and x y) x) simplifies to (eq/ne (and (not y) x) 0), which - can be implemented with a BICS instruction on some targets, or - constant-folded if y is a constant. */ + /* Simplify eq/ne (and/ior x y) x/y) for targets with a BICS instruction or + constant folding if x/y is a constant. */ if ((code == EQ || code == NE) - && op0code == AND - && rtx_equal_p (XEXP (op0, 0), op1) + && (op0code == AND || op0code == IOR) && !side_effects_p (op1) && op1 != CONST0_RTX (cmp_mode)) { - rtx not_y = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 1), cmp_mode); - rtx lhs = simplify_gen_binary (AND, cmp_mode, not_y, XEXP (op0, 0)); + /* Both (eq/ne (and x y) x) and (eq/ne (ior x y) y) simplify to + (eq/ne (and (not y) x) 0). */ + if ((op0code == AND && rtx_equal_p (XEXP (op0, 0), op1)) + || (op0code == IOR && rtx_equal_p (XEXP (op0, 1), op1))) + { + rtx not_y = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 1), + cmp_mode); + rtx lhs = simplify_gen_binary (AND, cmp_mode, not_y, XEXP (op0, 0)); - return simplify_gen_relational (code, mode, cmp_mode, lhs, - CONST0_RTX (cmp_mode)); - } + return simplify_gen_relational (code, mode, cmp_mode, lhs, + CONST0_RTX (cmp_mode)); + } - /* Likewise for (eq/ne (and x y) y). */ - if ((code == EQ || code == NE) - && op0code == AND - && rtx_equal_p (XEXP (op0, 1), op1) - && !side_effects_p (op1) - && op1 != CONST0_RTX (cmp_mode)) - { - rtx not_x = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 0), cmp_mode); - rtx lhs = simplify_gen_binary (AND, cmp_mode, not_x, XEXP (op0, 1)); + /* Both (eq/ne (and x y) y) and (eq/ne (ior x y) x) simplify to + (eq/ne (and (not x) y) 0). */ + if ((op0code == AND && rtx_equal_p (XEXP (op0, 1), op1)) + || (op0code == IOR && rtx_equal_p (XEXP (op0, 0), op1))) + { + rtx not_x = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 0), + cmp_mode); + rtx lhs = simplify_gen_binary (AND, cmp_mode, not_x, XEXP (op0, 1)); - return simplify_gen_relational (code, mode, cmp_mode, lhs, - CONST0_RTX (cmp_mode)); + return simplify_gen_relational (code, mode, cmp_mode, lhs, + CONST0_RTX (cmp_mode)); + } } /* (eq/ne (bswap x) C1) simplifies to (eq/ne x C2) with C2 swapped. */ |