[PATCH PR94026] combine missed opportunity to simplify comparisons with zero
Yangfei (Felix)
felix.yang@huawei.com
Fri Mar 13 03:21:18 GMT 2020
> -----Original Message-----
> From: Segher Boessenkool [mailto:segher@kernel.crashing.org]
> Sent: Friday, March 13, 2020 7:50 AM
> To: Yangfei (Felix) <felix.yang@huawei.com>
> Cc: gcc-patches@gcc.gnu.org; Zhanghaijian (A) <z.zhanghaijian@huawei.com>
> Subject: Re: [PATCH PR94026] combine missed opportunity to simplify
> comparisons with zero
>
> Hi!
>
> Please Cc: me on combine patches; you sent it nine days ago, and I didn't see it
> until now.
OK.
> On Wed, Mar 04, 2020 at 08:39:36AM +0000, Yangfei (Felix) wrote:
> > This is a simple fix for PR94026.
> > With this fix, combine will try make an extraction if we are in a equality
> comparison and this is an AND
> > with a constant which is power of two minus one. Shift here should be an
> constant. For example, combine
> > will transform (compare (and (lshiftrt x 8) 6) 0) to (compare (zero_extract
> (x 2 9)) 0).
>
> Why is that a good thing?
The reported test case is reduced from spec2017 541.leela_r. I have pasted original code snippet on the bugzilla.
We found other compilers like aocc/llvm can catch this pattern and simplify it.
> (There should be thorough tests on many archs, showing it helps on average,
> and it doesn't regress anything. I can do that for you, but not right now).
I only have aarch64 & x86_64 linux available and have tested this patch with spec17 on both platforms.
No obvious improvement & regression witnessed. This is expected as only one instruction is reduced here.
It's appreciated if this can be tested on other archs.
> The code needs more comments, and the commit message should say what is
> done and why you made those choices.
> In general, we should have *fewer* zero_extract, not more.
OK. I can add more comments & commit message if finally we are inclined to go with this patch.
Thanks,
Felix
More information about the Gcc-patches
mailing list