[Bug target/57583] large switches with jump tables are horribly broken on m68k

mikpe at it dot uu.se gcc-bugzilla@gcc.gnu.org
Wed Jun 12 11:37:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57583

--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> ---
It's not too difficult to make the m68k backend use 32-bit offsets in its jump
tables (adjust CASE_VECTOR_MODE, ASM_OUTPUT_ADDR_DIFF_ELT,
ASM_RETURN_CASE_JUMP, drop the sign-extend from the tablejump expander,
likewise in the unnamed insn that matches the output from the tablejump
expander).  I have a crude patch to do that, and make it compile-time
selectable via an option.

However, it seems to me that the compiler should be able to figure out for
itself if a given jump table might need 32-bit offsets.  In the worst case
every element will overflow a (signed) 16-bit offset (0..32K-1 positive range)
and need a GAS-inserted trampoline, for a total of 2 + 6 == 8 bytes per
element.  So tables with no more than 4K elements should work with 16-bit
offsets.  Tables larger than that may have their trampolines more than 32K away
from the table PC base, which cannot work with 16-bit offsets, so for those the
compiler should use 32-bit offsets.  Seems to require implementing "casesi" for
m68k though.



More information about the Gcc-bugs mailing list