[Bug tree-optimization/68274] __builtin_unreachable pessimizes code
matt at godbolt dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 10 16:53:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68274
--- Comment #2 from Matt Godbolt <matt at godbolt dot org> ---
Thanks for updating the bug. As a corollary, moving the unreachability above
the returns yields the same code as the non-unreachable: https://goo.gl/MdULOs
--
int test_with_unreach_First(Side side, const Foo &foo) {
if (side != Ask && side != Bid) __builtin_unreachable();
if (side == Bid) return foo.a;
return foo.b;
}
--
test_with_unreach_First(Side, Foo const&):
mov eax, DWORD PTR [rsi+4]
test edi, edi
cmove eax, DWORD PTR [rsi]
ret
--
For what it's worth I've been unable to coax either clang or icc (13.0.1
anyway) into the code I'd ideally like (the rsi+eax*4 case).
More information about the Gcc-bugs
mailing list