diff options
author | Kyrylo Tkachov <kyrylo.tkachov@arm.com> | 2016-09-19 16:15:57 +0000 |
---|---|---|
committer | Kyrylo Tkachov <ktkachov@gcc.gnu.org> | 2016-09-19 16:15:57 +0000 |
commit | 5fa9e6441ff5169f90d0754b2321d3ddffad89fa (patch) | |
tree | a7379f1fefea79b97de434568bc40379bfc7ce2f /gcc/simplify-rtx.c | |
parent | ee1ab3e3c2296a7cea60f0b1d92a5b3d9cc4cae3 (diff) | |
download | gcc-5fa9e6441ff5169f90d0754b2321d3ddffad89fa.zip gcc-5fa9e6441ff5169f90d0754b2321d3ddffad89fa.tar.gz gcc-5fa9e6441ff5169f90d0754b2321d3ddffad89fa.tar.bz2 |
[simplify-rtx] (GTU (PLUS a C) (C - 1)) --> (LTU a -C)
* simplify-rtx.c (simplify_relational_operation_1): Add transformation
(GTU (PLUS a C) (C - 1)) --> (LTU a -C).
* gcc.target/aarch64/gtu_to_ltu_cmp_1.c: New test.
* gcc.target/aarch64/gtu_to_ltu_cmp_2.c: New test.
From-SVN: r240238
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 8daef97..035f70e 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -4650,6 +4650,19 @@ simplify_relational_operation_1 (enum rtx_code code, machine_mode mode, cmp_mode, XEXP (op0, 0), new_cmp); } + /* (GTU (PLUS a C) (C - 1)) where C is a non-zero constant can be + transformed into (LTU a -C). */ + if (code == GTU && GET_CODE (op0) == PLUS && CONST_INT_P (op1) + && CONST_INT_P (XEXP (op0, 1)) + && (UINTVAL (op1) == UINTVAL (XEXP (op0, 1)) - 1) + && XEXP (op0, 1) != const0_rtx) + { + rtx new_cmp + = simplify_gen_unary (NEG, cmp_mode, XEXP (op0, 1), cmp_mode); + return simplify_gen_relational (LTU, mode, cmp_mode, + XEXP (op0, 0), new_cmp); + } + /* Canonicalize (LTU/GEU (PLUS a b) b) as (LTU/GEU (PLUS a b) a). */ if ((code == LTU || code == GEU) && GET_CODE (op0) == PLUS |