https://bugs.llvm.org/show_bug.cgi?id=46279
Bug ID: 46279
Summary: Unnecessary branch with -fstrict-enums
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
This code:
#include <stdlib.h>
enum Foo {
A,
B,
C,
};
Foo foo(Foo* data) {
Foo k = data[1];
if (k > Foo::C) {
exit(3);
}
return k;
}
compiles with -fstrict-enums to:
foo(Foo*): # @foo(Foo*)
pushq %rax
movl 4(%rdi), %eax
cmpl $3, %eax
je .LBB0_2
popq %rcx
retq
.LBB0_2:
movl $3, %edi
callq exit
It should be possible to elide the call to exit()
Interestingly enough, without -fstrict-enums the je becomes jge so LLVM has
some idea about what's going on.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs