This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/82404] Unnecessary instructions in switch table
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 03 Oct 2017 08:07:40 +0000
- Subject: [Bug middle-end/82404] Unnecessary instructions in switch table
- Auto-submitted: auto-generated
- References: <bug-82404-4@http.gcc.gnu.org/bugzilla/>
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
...