On 21/07/15 11:46, pins...@gmail.com wrote:



On Jul 21, 2015, at 3:31 AM, Kyrill Tkachov <kyrylo.tkac...@arm.com> wrote:


On 21/07/15 10:26, pins...@gmail.com wrote:



On Jul 21, 2015, at 2:15 AM, Hurugalawadi, Naveen 
<naveen.hurugalaw...@caviumnetworks.com> wrote:

Hi,

Please find attached the patch which performs following patterns folding
in match.pd:-

a ==/!= a p+ b to b ==/!= 0.
a << N ==/!= 0 to a&(-1>>N) ==/!= 0.
a * N ==/!= 0 where N is a power of 2 to a & (-1<<N2) ==/!= 0 where N2 is log2 
of N.

Please review the same and let us know if its okay?
I should note this shows up in perlbmk in spec 2006.
Yes, I see it triggering there for aarch64, but I also see some undesired 
effects,
for example in gcc:
    lsl    x24, x24, 3
    cbz    x24, .L1194

now becomes:
    and    x0, x24, 2305843009213693951
    lsl    x24, x24, 3
    cbz    x0, .L1194
Shouldn't the and become a tst instead and the cbz be a b.eq?  Oh I have 
another patch which does that and the reason the performance for me does not 
regress on thunderx (tst and branches can merge before issue).

I also see a code size regression on xalancbmk.
If you have an aarch64 patch that mitigates this there, could you post that as 
well?
Would be nice to get the benefits of this folding without regressing existing 
cases on aarch64.

Thanks,
Kyrill


Thanks,
Andrew

Thanks,
Andrew

Regression Tested on X86_64.

On Behalf of Andrew Pinski.

Thanks,

gcc/testsuite/ChangeLog:

2015-01-21  Andrew Pinski  <apin...@cavium.com>

    * testsuite/gcc.dg/tree-ssa/compare-shiftmult-1.c: New testcase.
    * testsuite/gcc.dg/tree-ssa/compare_pointers-1.c: New testcase.

gcc/ChangeLog:

2015-01-21  Andrew Pinski  <apin...@cavium.com>

    * match.pd (define_predicates): Add integer_pow2p.
    Add pattern for folding of a ==/!= a p+ b to b ==/!= 0.
    (unsigned_integral_valued_p): New match.
    Add pattern for folding of a<<N ==/!= 0 to a&(-1>>N) ==/!= 0.
    Add pattern for folding of a*N ==/!= 0 where N is a power of 2
    to a&(-1<<N2) ==/!= 0 where N2 is log2 of N.
<gcc_match.patch>

Reply via email to