On Tue, Jul 21, 2015 at 12:16 PM, Richard Biener <richard.guent...@gmail.com> wrote: > On July 21, 2015 11:38:31 AM GMT+02:00, Jakub Jelinek <ja...@redhat.com> > wrote: >>On Tue, Jul 21, 2015 at 09:15:31AM +0000, Hurugalawadi, Naveen wrote: >>> 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. >> >>Not sure about this second one. Why do you think it is generally >>beneficial? On many targets, shifts are as fast as bitwise and, and >>-1>>N could be e.g. significantly more expensive constant (say require >>3 instructions to construct). > > And may set flags while shift not? Of course we do a very poor job of > representing this kind of stuff on gimple.
The biggest question now becomes which way is the canonical form for gimple and we can decide to optimize it on the RTL level (combine) instead if it produces better code in those cases. Note on AARCH64, producing x&(-1>>N) has no cost difference from a<<N so we would like to do it there. Also in this case producing flags is useful. Thanks, Andrew > > Richard. > >> Jakub > >