diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-03 16:22:09 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-03 16:22:09 +0000 |
commit | b114d7da29b2d7eaf56ea20d0f66ffb67449d691 (patch) | |
tree | bfb24c386a49e21499491718ab79c1846ad1b956 /gcc | |
parent | 2f7e7db3869a7e8db362d2225a0dcce1e7eec6f5 (diff) | |
download | gcc-b114d7da29b2d7eaf56ea20d0f66ffb67449d691.tar.gz |
* simplify-rtx.c (simplify_relational_operation_1): Implement some
canonicalization transformations that attempt to simplify integer
constant comparisons to become comparisons against zero.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121544 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 78 |
2 files changed, 65 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6fa2af1860f..e6cfa7cf548 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-02-03 Roger Sayle <roger@eyesopen.com> + + * simplify-rtx.c (simplify_relational_operation_1): Implement some + canonicalization transformations that attempt to simplify integer + constant comparisons to become comparisons against zero. + 2007-02-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * builtins.c (fold_builtin_cabs): Fold cabs(x+xi) into diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 0ce80c7f6c2..f04f0521e35 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)) */ |