[Bug middle-end/82404] Unnecessary instructions in switch table
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 3 08:07:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82404
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I can confirm in C, clang adds guard checks:
$ cat pr82405-2.c
enum eShape { eSquare, eCircle, eShpere, eTetraeder };
double test_switch_native(enum eShape shape, double r) {
switch(shape) {
case eSquare: return 2;
case eCircle: return 3;
case eShpere: return 4;
case eTetraeder: return 5;
}
}
$ clang pr82405-2.c -O2 -o/dev/stdout -S
test_switch_native: # @test_switch_native
.cfi_startproc
# BB#0:
cmpl $3, %edi
ja .LBB0_2
# BB#1:
movslq %edi, %rax
movsd .Lswitch.table(,%rax,8), %xmm0 # xmm0 = mem[0],zero
...
More information about the Gcc-bugs
mailing list