[patch] Small enhancement to associate_plusminus
Richard Biener
richard.guenther@gmail.com
Thu May 22 08:07:00 GMT 2014
On Wed, May 21, 2014 at 9:45 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> one of the transformations performed by associate_plusminus is:
>
> /* Second match patterns that allow contracting a plus-minus pair
> irrespective of overflow issues.
>
> [...]
> (T)(P + A) - (T)P -> (T)A
>
> but it is actually applied only to POINTER_PLUS_EXPR and pointer types:
>
> /* (T)(ptr + adj) - (T)ptr -> (T)adj. */
>
> It turns out that this pattern arises for size computations of array slices in
> Ada, which are done in integer types; for the attached testcase, extending the
> transformation to integer types makes it possible to eliminate a call to the
> alloca builtin.
>
> Tested on x86_64-suse-linux, OK for the mainline?
I'm a little worried that introducing PLUS_EXPR_CODE_P and friends
invites too easy (not well thought) uses of it - they are distinct enough
that we have very few "common" code-paths given the constraints on
op2 of POINTER_PLUS_EXPR.
Thus I'd say ok without adding those.
Thanks,
Richard.
> 2014-05-21 Eric Botcazou <ebotcazou@adacore.com>
>
> * tree.h (PLUS_EXPR_CODE_P): New macro.
> (PLUS_EXPR_P): Likewise.
> (CASE_PLUS): Likewise.
> * tree-ssa-forwprop.c (associate_plusminus): Extend (T)(P+A) - (T)P
> -> (T)A transformation to integer types.
>
>
> 2014-05-21 Eric Botcazou <ebotcazou@adacore.com>
>
> * gnat.dg/opt37.ad[sb]: New test.
>
>
> --
> Eric Botcazou
More information about the Gcc-patches
mailing list