[Bug tree-optimization/79472] [7 Regression] x86-64: Switch table generation fails if default case has different code

yuriks at yuriks dot net gcc-bugzilla@gcc.gnu.org
Mon Feb 13 09:51:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79472

--- Comment #4 from Yuri Kunde Schlesner <yuriks at yuriks dot net> ---
Note that, while this particular example uses a noreturn call, the same pattern
applies to any switch where the default case is the only one which has code
that can't be transformed into a table. For example, replacing `abort();` with
`s = external_getstr();` (`const char* external_getstr();`) follows the same
pattern in all compilers (gcc 6.3 can optimize to table with the nullptr hack,
clang can always optimize, gcc 7 can't optimize at all).

Another thing I noticed is that gcc 6.3 still leaves in the nullptr check after
the switch, even though it's actually unreachable at that point. (Probably out
of scope for this bug though.)


More information about the Gcc-bugs mailing list