https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93326
Bug ID: 93326
Summary: switch optimisation of multiple jumptables into a
lookup
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.von.s at posteo dot de
Target Milestone: ---
Target: i686-linux-gnu
Attached two code samples are equivalent, yet they are optimised wildly
differently (with -O3 -fno-pic).
Apparently, GCC is capable of recognising that a switch/return realised by a
single jumptable can be optimised into a lookup table, but is unable to do so
when a switch is realised by multiple jumptables.
When compiling in PIC mode, neither switch is optimised into a lookup table; I
don't see a reason why it couldn't be.