Fold some equal to and not equal to patterns in match.pd

Kyrill Tkachov kyrylo.tkachov@arm.com
Tue Jul 21 11:09:00 GMT 2015


On 21/07/15 11:46, pinskia@gmail.com wrote:
>
>
>
>> On Jul 21, 2015, at 3:31 AM, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:
>>
>>
>>> On 21/07/15 10:26, pinskia@gmail.com wrote:
>>>
>>>
>>>
>>>> On Jul 21, 2015, at 2:15 AM, Hurugalawadi, Naveen <Naveen.Hurugalawadi@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).

well, the overall effect in perlbench and gcc is beneficial (at least code size-wise).
It's just a few warts like this here and there.

Kyrill

>
> Thanks,
> Andrew
>
>>> Thanks,
>>> Andrew
>>>
>>>> Regression Tested on X86_64.
>>>>
>>>> On Behalf of Andrew Pinski.
>>>>
>>>> Thanks,
>>>>
>>>> gcc/testsuite/ChangeLog:
>>>>
>>>> 2015-01-21  Andrew Pinski  <apinski@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  <apinski@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>



More information about the Gcc-patches mailing list