[Bug middle-end/65922] New: Switch statement with __builtin_unreachable creates a wild branch
bergner at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 29 01:28:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65922
Bug ID: 65922
Summary: Switch statement with __builtin_unreachable creates a
wild branch
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: bergner at gcc dot gnu.org
Target Milestone: ---
The following test case compiled with -O2 creates a wild branch when it
generates the branch to the switch's "default" leg. On both POWER and x86_64
(maybe others), it generates a branch with a label just past the last
instruction in the function.
POWER:
.L.foo:
cmplwi 7,4,6
bgt 7,.L2
[snip]
blr
.p2align 4,,15
.L2:
.long 0
X86_64:
foo:
.LFB0:
.cfi_startproc
cmpl $6, %esi
ja .L2
[snip]
ret
.p2align 4,,10
.p2align 3
.L2:
.cfi_endproc
.LFE0:
.size foo, .-foo
My guess is that since we've stated that the default leg is unreachable, we
should probably just delete the branch altogether, rather than allowing it to
branch into nowhere. I'll note that I see the same behavior from GCC 4.8 thru
trunk. The code from GCC 4.7 and earlier looks ok.
More information about the Gcc-bugs
mailing list