This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.5] Doloop improvement patches, 3/7
- From: Bernd Schmidt <bernds_cb1 at t-online dot de>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 05 Mar 2009 22:31:29 +0000
- Subject: [4.5] Doloop improvement patches, 3/7
- References: <49B04F62.5060007@t-online.de>
For unsigned comparisons, the two following expressions are equivalent:
A + B < A <=> A + B < B
If B is a constant, this is also equivalent to
A >= -B
The latter form is simpler and should be used if possible; this patch
teaches simplify_relational_operation_1 about it. This helps with
certain expressions seen when trying to prove facts about doloops.
Bernd
* simplify-rtx.c (simplify_relational_operation_1): Convert unsigned
comparisons of the form (X + CONST) < CONST to X >= -CONST.
Index: gcc/simplify-rtx.c
===================================================================
--- gcc.orig/simplify-rtx.c
+++ gcc/simplify-rtx.c
@@ -3856,6 +3856,21 @@ simplify_relational_operation_1 (enum rt
}
}
+ /* (LTU/GEU (PLUS a C) C), where C is constant, can be simplified to
+ (GEU/LTU a -C). */
+ if ((code == LTU || code == GEU)
+ && GET_CODE (op0) == PLUS
+ && GET_CODE (XEXP (op0, 1)) == CONST_INT
+ && (rtx_equal_p (op1, XEXP (op0, 0))
+ || rtx_equal_p (op1, XEXP (op0, 1))))
+ {
+ HOST_WIDE_INT new_cmp
+ = trunc_int_for_mode (-INTVAL (XEXP (op0, 1)), cmp_mode);
+ return simplify_gen_relational ((code == LTU ? GEU : LTU), mode,
+ cmp_mode, XEXP (op0, 0),
+ GEN_INT (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