This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.5] Doloop improvement patches, 3/7


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]