aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2002-06-07 23:50:31 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2002-06-07 23:50:31 +0000
commitbc9c18c3193347c70989e21c036cc5c298021569 (patch)
tree5f3c718932f00c23a8fca6901ef2f8a9bc17139e
parent437f1df1afacb10132608f3cf27f4289c1bdbe1c (diff)
downloadgcc-bc9c18c3193347c70989e21c036cc5c298021569.zip
gcc-bc9c18c3193347c70989e21c036cc5c298021569.tar.gz
gcc-bc9c18c3193347c70989e21c036cc5c298021569.tar.bz2
simplify-rtx.c (simplify_gen_relational): Simplify RTL of the form (ne (comp x y) 0) into (comp x y) where comp is a...
* simplify-rtx.c (simplify_gen_relational): Simplify RTL of the form (ne (comp x y) 0) into (comp x y) where comp is a comparison code. Simplify (eq (comp x y) 0) into (revcomp x y) if the sense of the comparison code comp can be reversed. From-SVN: r54357
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/simplify-rtx.c21
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index afff77b..f07f710 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2002-06-07 Roger Sayle <roger@eyesopen.com>
+ * simplify-rtx.c (simplify_gen_relational): Simplify RTL of the form
+ (ne (comp x y) 0) into (comp x y) where comp is a comparison code.
+ Simplify (eq (comp x y) 0) into (revcomp x y) if the sense of the
+ comparison code comp can be reversed.
+
+2002-06-07 Roger Sayle <roger@eyesopen.com>
+
* fold-const.c (fold) [EQ_EXPR]: Place both integer and real
constants last in comparisons. Optimize (x+1.0)>0.0 into the
equivalent x > -1.0 when -ffast-math.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 6ec33a3..5db501e 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -232,10 +232,31 @@ simplify_gen_relational (code, mode, cmp_mode, op0, op1)
if ((tem = simplify_relational_operation (code, cmp_mode, op0, op1)) != 0)
return tem;
+ /* For the following tests, ensure const0_rtx is op1. */
+ if (op0 == const0_rtx && swap_commutative_operands_p (op0, op1))
+ tem = op0, op0 = op1, op1 = tem, code = swap_condition (code);
+
/* If op0 is a compare, extract the comparison arguments from it. */
if (GET_CODE (op0) == COMPARE && op1 == const0_rtx)
op1 = XEXP (op0, 1), op0 = XEXP (op0, 0);
+ /* If op0 is a comparison, extract the comparison arguments form it. */
+ if (code == NE && op1 == const0_rtx
+ && GET_RTX_CLASS (GET_CODE (op0)) == '<')
+ return op0;
+ else if (code == EQ && op1 == const0_rtx)
+ {
+ /* The following tests GET_RTX_CLASS (GET_CODE (op0)) == '<'. */
+ enum rtx_code new = reversed_comparison_code (op0, NULL_RTX);
+ if (new != UNKNOWN)
+ {
+ code = new;
+ mode = cmp_mode;
+ op1 = XEXP (op0, 1);
+ op0 = XEXP (op0, 0);
+ }
+ }
+
/* Put complex operands first and constants second. */
if (swap_commutative_operands_p (op0, op1))
tem = op0, op0 = op1, op1 = tem, code = swap_condition (code);