[Bug tree-optimization/91026] New: switch expansion produces a jump table with trivial entries
rafael at espindo dot la
gcc-bugzilla@gcc.gnu.org
Fri Jun 28 01:33:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91026
Bug ID: 91026
Summary: switch expansion produces a jump table with trivial
entries
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rafael at espindo dot la
Target Milestone: ---
Created attachment 46531
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46531&action=edit
testcase
In the attached testcase gcc lowers the switch to a jump table where each entry
in the table just sets a value. The two labels in the table are
.L5:
movl $1, %eax
ret
.L2:
xorl %eax, %eax
ret
gcc could have replaced the jump table with a constant table, with L5 replaced
by 1 and L2 by 0.
clang produces:
0000000000000000 <_Z3foo4kind>:
0: 40 80 c7 ff add $0xff,%dil
4: 40 80 ff 11 cmp $0x11,%dil
8: 77 0c ja 16 <_Z3foo4kind+0x16>
a: b8 b9 a7 02 00 mov $0x2a7b9,%eax
f: 89 f9 mov %edi,%ecx
11: d3 e8 shr %cl,%eax
13: 24 01 and $0x1,%al
15: c3 retq
16: 31 c0 xor %eax,%eax
18: c3 retq
More information about the Gcc-bugs
mailing list