[PATCH] Implement switch statements with bit tests
Andi Kleen
ak@suse.de
Fri Jan 24 12:49:00 GMT 2003
> > #define CASE_USE_BIT_TESTS 0
> >
> > [Is there a better way to test for an efficient left shift insn?]
>
> Yes, there is. Use rtx_cost().
I think you still need a target macro. Some architectures have undefined
behaviour when the left shift is bigger than the word size
(e.g. the vax can trap and others may need a long time to execute
the shift) For these an and WORDSIZE-1,... before the mask is needed.
As it may be hard to figure out which of the many architectures
gcc supports have this problem it may be a better idea to just
turn it on when the target macro is set. I believe all modern
architectures in wide use (ppc,alpha,i386,mips etc.) do the AND
already in the CPU.
-Andi
More information about the Gcc-patches
mailing list