This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The arm patch 161344 to transform TST into LSLS


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]