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: [patch] Move lowering of switches to bit tests to GIMPLE


On Fri, Jul 20, 2012 at 12:41 AM, Richard Henderson <rth@redhat.com> wrote:
> Notes for future cleanups:
>
>> +  /* If the targer has no lshift in word_mode, the operation will most
>> +     probably not be cheap.  ??? Does GCC even work for such targets?  */
>
> Yes, it does.  We're perfectly happy to let this expand to a libcall.  Indeed, many teeny tiny targets don't have a full barrel shifter and only implement x << 1.  See sh1, avr, etc.

Thanks for those references! I'll fix this comment with some
references into the machine descriptions of those ports.


>> +      int cost = set_src_cost (gen_rtx_ASHIFT (word_mode, const1_rtx, reg),
> ...
>> +if CST constains at least 3 bits, and "x << 1" is cheap.  The bit tests are
>
> Code is correct, comment is incorrect: 1 << x.

Fixed that now.


>> +* The compounded constant could be shifted rather than the one.  The
>> +  test would be either on the sign bit or on the least significant bit,
>> +  depending on the direction of the shift.  On some machines, the test
>> +  for the branch would be free if the bit to test is already set by the
>> +  shift operation.
>
> I'm reasonably certain that this would be an improvement for most targets.

It probably is an improvement for most targets if there are just two
target basic blocks (one for the default case, and one for all
non-default cases). With more than one target block for the
non-default cases, you have to shift the compound constant for every
test. That's why Roger didn't implement this (see
http://gcc.gnu.org/ml/gcc-patches/2003-01/msg01796.html).

I plan to implement this transformation for the simple
1-non-default-target, but it isn't very high on my TODO list...

Thanks for the review!
(Oh, and sorry for the CODE_FOR_nothing == 0 breakage! :-)

Ciao!
Steven


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