diff options
author | sandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-09 02:53:00 +0000 |
---|---|---|
committer | sandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-09 02:53:00 +0000 |
commit | 7a542b16e34cfb40fe37fab74a119e80a1a55587 (patch) | |
tree | cd75cdabae8e92253d9371bd0dae743d7c9e863d /gcc/simplify-rtx.c | |
parent | 9dac2720f30b6a3271d55c67cd79a3d90c11c2ed (diff) | |
download | gcc-7a542b16e34cfb40fe37fab74a119e80a1a55587.tar.gz |
2014-12-08 Sandra Loosemore <sandra@codesourcery.com>
gcc/
* simplify-rtx.c (simplify_relational_operation_1): Handle
simplification identities for BICS patterns.
gcc/testsuite/
* gcc.target/aarch64/bics_4.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218503 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 055ba787ac6..1cbb157dc71 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -4550,6 +4550,32 @@ 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. */ + if ((code == EQ || code == NE) + && op0code == AND + && rtx_equal_p (XEXP (op0, 0), op1) + && !side_effects_p (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); + } + + /* 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)) + { + 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); + } + /* (eq/ne (bswap x) C1) simplifies to (eq/ne x C2) with C2 swapped. */ if ((code == EQ || code == NE) && GET_CODE (op0) == BSWAP |