Tiny combine tweek

Zack Weinberg zack@codesourcery.com
Wed Jun 4 20:46:00 GMT 2003


Jan Hubicka <jh@suse.cz> writes:

>> > 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.

Wouldn't it be better to notice that the pair of shifts is a noop at
the time the IF_THEN_ELSE construct would otherwise be generated?

zw



More information about the Gcc-patches mailing list