This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Tiny combine tweek
> Jan Hubicka <jh@suse.cz> writes:
>
> >> Jan Hubicka <jh@suse.cz> writes:
> >>
> >> > Hi,
> >> > Michael noticed that combine sometimes confuses itself by creating such
> >> > a noop if_then_else construct out of nontrivial noop expressions having
> >> > register operand with only two possible values.
> >> >
> >> > Regtested/bootstrapped mainline, OK?
> >>
> >> Test case?
> >
> > int
> > t(int a)
> > {
> > a=a&8;
> > a=a<<1;
> > a=a>>1;
> > return a;
> > }
> > don't need to do the shifts. GCC used to simplify this but it does not
> > do that anymore.
>
> I'm sick and not thinking clearly ... could you please explain in
> small words how we get an IF_THEN_ELSE construct out of that?
Combine sees (a<<1)>>1 expression and decides to be smart by noticing
that a has two possible values (via nonzero_bits). It converts it then
a?const1:const2 early instead of noticing that the shifts are noops.
Honza
>
> zw