This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: The arm patch 161344 to transform TST into LSLS
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Carrot Wei <carrot at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 02 Jul 2010 10:15:53 +0100
- Subject: Re: The arm patch 161344 to transform TST into LSLS
- References: <AANLkTiksLOQr405hWvbRHXMj1n4eZD0GAx7KlShJoWA2@mail.gmail.com>
On Fri, 2010-07-02 at 08:53 +0800, Carrot Wei wrote:
> Hi Richard
>
> The new peephole2 and the old pattern does different optimization. As
> you have described the peephole2 can optimize the cases that test a
> single bit in a word. But the old pattern tests if the bit fields at
> the low end of a word is equal or not equal to zero, the bit field may
> contain more than 1 bit. Interestingly the test case with the old
> pattern can fit in both situations. If we change the test case as
> following, it can show the regression.
>
> struct A
> {
> int v:2;
> };
>
>
> int bar();
> int foo(struct A* p)
> {
> if (p->v)
> return 1;
> return bar();
> }
>
> So we need another peephole2 to bring that optimization back.
>
> thanks
> Guozhi
Yes, a peep2 for that should be pretty straight-forward to generate.
Simply transform the code into a left-shift and compare with 0, then a
branch if eq/ne.
R.