diff options
author | Roger Sayle <roger@eyesopen.com> | 2007-02-03 16:22:09 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2007-02-03 16:22:09 +0000 |
commit | 3fa0cacdb544ea4519f9c783f0d3a8cb5347db28 (patch) | |
tree | bfb24c386a49e21499491718ab79c1846ad1b956 /gcc/simplify-rtx.c | |
parent | 5041541e41d601397af25539d0c94cccff320188 (diff) | |
download | gcc-3fa0cacdb544ea4519f9c783f0d3a8cb5347db28.zip gcc-3fa0cacdb544ea4519f9c783f0d3a8cb5347db28.tar.gz gcc-3fa0cacdb544ea4519f9c783f0d3a8cb5347db28.tar.bz2 |
simplify-rtx.c (simplify_relational_operation_1): Implement some canonicalization transformations that attempt to simplify...
* simplify-rtx.c (simplify_relational_operation_1): Implement some
canonicalization transformations that attempt to simplify integer
constant comparisons to become comparisons against zero.
From-SVN: r121544
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 0ce80c7..f04f052 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3595,28 +3595,68 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode, { enum rtx_code op0code = GET_CODE (op0); - if (GET_CODE (op1) == CONST_INT) + if (op1 == const0_rtx && COMPARISON_P (op0)) { - if (INTVAL (op1) == 0 && COMPARISON_P (op0)) + /* If op0 is a comparison, extract the comparison arguments + from it. */ + if (code == NE) { - /* If op0 is a comparison, extract the comparison arguments - from it. */ - if (code == NE) - { - if (GET_MODE (op0) == mode) - return simplify_rtx (op0); - else - return simplify_gen_relational (GET_CODE (op0), mode, VOIDmode, - XEXP (op0, 0), XEXP (op0, 1)); - } - else if (code == EQ) - { - enum rtx_code new_code = reversed_comparison_code (op0, NULL_RTX); - if (new_code != UNKNOWN) - return simplify_gen_relational (new_code, mode, VOIDmode, - XEXP (op0, 0), XEXP (op0, 1)); - } + if (GET_MODE (op0) == mode) + return simplify_rtx (op0); + else + return simplify_gen_relational (GET_CODE (op0), mode, VOIDmode, + XEXP (op0, 0), XEXP (op0, 1)); } + else if (code == EQ) + { + enum rtx_code new_code = reversed_comparison_code (op0, NULL_RTX); + if (new_code != UNKNOWN) + return simplify_gen_relational (new_code, mode, VOIDmode, + XEXP (op0, 0), XEXP (op0, 1)); + } + } + + if (op1 == const0_rtx) + { + /* Canonicalize (GTU x 0) as (NE x 0). */ + if (code == GTU) + return simplify_gen_relational (NE, mode, cmp_mode, op0, op1); + /* Canonicalize (LEU x 0) as (EQ x 0). */ + if (code == LEU) + return simplify_gen_relational (EQ, mode, cmp_mode, op0, op1); + } + else if (op1 == const1_rtx) + { + switch (code) + { + case GE: + /* Canonicalize (GE x 1) as (GT x 0). */ + return simplify_gen_relational (GT, mode, cmp_mode, + op0, const0_rtx); + case GEU: + /* Canonicalize (GEU x 1) as (NE x 0). */ + return simplify_gen_relational (NE, mode, cmp_mode, + op0, const0_rtx); + case LT: + /* Canonicalize (LT x 1) as (LE x 0). */ + return simplify_gen_relational (LE, mode, cmp_mode, + op0, const0_rtx); + case LTU: + /* Canonicalize (LTU x 1) as (EQ x 0). */ + return simplify_gen_relational (EQ, mode, cmp_mode, + op0, const0_rtx); + default: + break; + } + } + else if (op1 == constm1_rtx) + { + /* Canonicalize (LE x -1) as (LT x 0). */ + if (code == LE) + return simplify_gen_relational (LT, mode, cmp_mode, op0, const0_rtx); + /* Canonicalize (GT x -1) as (GE x 0). */ + if (code == GT) + return simplify_gen_relational (GE, mode, cmp_mode, op0, const0_rtx); } /* (eq/ne (plus x cst1) cst2) simplifies to (eq/ne x (cst2 - cst1)) */ |