This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [4.5] Doloop improvement patches, 3/7
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Bernd Schmidt <bernds_cb1 at t-online dot de>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 6 Mar 2009 00:53:14 +0100
- Subject: Re: [4.5] Doloop improvement patches, 3/7
- References: <49B052C1.4070000@t-online.de>
Hi,
> 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));
I am not sure about the way the new operand for comparison is produced;
what about
simplify_gen_unary (NEG, cmp_mode, XEXP (op0, 1), cmp_mode)?
Anyway, someone else has to approve this change.
Zdenek