aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2004-12-20 21:48:53 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2004-12-20 20:48:53 +0000
commitbc4ad38cc7c461d23be503a19de56f7514e077a8 (patch)
treee67767d6419a11c4c59f9932d6fc878f8e013a5b
parentb482789cca42c2e1c3d0c7dd1c140fe3e5e320a2 (diff)
downloadgcc-bc4ad38cc7c461d23be503a19de56f7514e077a8.zip
gcc-bc4ad38cc7c461d23be503a19de56f7514e077a8.tar.gz
gcc-bc4ad38cc7c461d23be503a19de56f7514e077a8.tar.bz2
re PR rtl-optimization/18942 (Do loop is not as optimized as 3.3.2)
PR rtl-optimization/18942 * simplify-rtx.c (simplify_relational_operation_1): Simplify x + cst1 == cst2 to x == cst2 - cst1. Made static. From-SVN: r92429
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/simplify-rtx.c19
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db153d5..45c0a27 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-20 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR rtl-optimization/18942
+ * simplify-rtx.c (simplify_relational_operation_1): Simplify
+ x + cst1 == cst2 to x == cst2 - cst1. Made static.
+
2004-12-20 Matt Austern <austern@apple.com>
PR c++/19044
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 5feeb65..8d7cb3f 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -2773,10 +2773,13 @@ simplify_relational_operation (enum rtx_code code, enum machine_mode mode,
MODE is the mode of the result, while CMP_MODE specifies in which
mode the comparison is done in, so it is the mode of the operands. */
-rtx
+
+static rtx
simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
enum machine_mode cmp_mode, rtx op0, rtx op1)
{
+ enum rtx_code op0code = GET_CODE (op0);
+
if (GET_CODE (op1) == CONST_INT)
{
if (INTVAL (op1) == 0 && COMPARISON_P (op0))
@@ -2800,6 +2803,20 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
}
}
+ /* (eq/ne (plus x cst1) cst2) simplifies to (eq/ne x (cst2 - cst1)) */
+ if ((code == EQ || code == NE)
+ && (op0code == PLUS || op0code == MINUS)
+ && CONSTANT_P (op1)
+ && CONSTANT_P (XEXP (op0, 1)))
+ {
+ rtx x = XEXP (op0, 0);
+ rtx c = XEXP (op0, 1);
+
+ c = simplify_gen_binary (op0code == PLUS ? MINUS : PLUS,
+ cmp_mode, op1, c);
+ return simplify_gen_relational (code, mode, cmp_mode, x, c);
+ }
+
return NULL_RTX;
}