[PATCH] Optimize certain end of loop conditions into min/max operation

Michael Collison michael.collison@linaro.org
Thu Oct 1 05:40:00 GMT 2015


Richard and Marc,

Latest patch attached which incorporates all comments.

2015-09-30  Michael Collison <michael.collison@linaro.org>
         Andrew Pinski <andrew.pinski@caviumnetworks.com>

     * match.pd ((x < y) && (x < z) -> x < min (y,z),
     (x > y) and (x > z) -> x > max (y,z))
     * testsuite/gcc.dg/tree-ssa/minmax-loopend.c: New test.

On 09/30/2015 12:30 PM, Marc Glisse wrote:
>>>>>> On Fri, 18 Sep 2015, Marc Glisse wrote:
>>>>>>>> +(bit_and:c (op @0 @1) (op @0 @2))
>>>>>>>
>>>>>>> :c seems useless here. On the other hand, it might make sense to 
>>>>>>> use op:s
>>>>>>> since this is mostly useful if it removes the 2 original 
>>>>>>> comparisons.
>
> As I was saying, :c is useless.
> (x:c y z)
> is replaced by two copies of the transformation, one with
> (x y z)
> and the other with
> (x z y)
> In your transformation, both versions would be equivalent, so the second
> one is redundant.
>
> Also, if you have:
> a=x<y;
> b=x<z;
> c=a&b;
> reuse(a);
> reuse(b);
>
> (i.e. the comparison results are used for more than just this bit_and)
> then your transformation may make the code more expensive. To avoid
> this, you can write op:s, meaning that the result of op is used only
> once.
>

-- 
Michael Collison
Linaro Toolchain Working Group
michael.collison@linaro.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tcwg-140-v7.patch
Type: text/x-patch
Size: 1279 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151001/cdf8c926/attachment.bin>


More information about the Gcc-patches mailing list