https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123212
Bug ID: 123212
Summary: GCC 15 no longer compiles switch statements to jump
tables by default with Og
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: toadster172 at gmail dot com
Target Milestone: ---
GCC 15 seems to enable -fnojump-tables by default in O0 and Og, resulting in
rather horrid codegen for large switch statements where previous versions would
generate jump tables.
Trivial example in Godbolt (O1 generates a jump table, as do versions of GCC
before 15.1): https://godbolt.org/z/KKnq8xfn6
I understand that O0 mean no optimizations (though I can't say I see a reason
to add -fno-jump-tables as the default there), but this doesn't seem like it
fits what would be expected from Og. At the very least, GCC's documentation is
out of date, as the list of flag differences between Og and O1 in the manual
doesn't include -fjump-tables.