https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95208
Bug ID: 95208
Summary: missed switch optimization as bit test
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: nathan at gcc dot gnu.org
Target Milestone: ---
Created attachment 48565
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48565&action=edit
The if case is optimized better
This comes from libcpp/lex.c's raw string lexer. We're testing whether a
character falls into a particular set of values. The switch is emitted as the
usual dispatch table. The if case, after range checking, turns into
'if ((1ul << (c - BASE)) & MAGIC_VALUE)' Which is somewhat better. Why
doesn't the switch form do that?
_Z3bazc:
.LFB1:
.cfi_startproc
leal -97(%rdi), %eax
cmpb $29, %al
jbe .L7
subl $33, %edi
cmpb $62, %dil
ja .L6
movabsq $8646911282403868279, %rax
btq %rdi, %rax
jc .L7
.L6:
ret
.p2align 4,,10
.p2align 3
.L7:
jmp _Z3barv
.cfi_endproc