https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125814
Bug ID: 125814
Summary: Possible Missed Optimization at O3
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: apowenq at gmail dot com
Target Milestone: ---
cat prog.c
int src(int v1_u8) {
if (!((2 <= v1_u8) && (v1_u8 <= 3))) __builtin_unreachable();
int i0_u8 = 5 - v1_u8;
int i1_u8 = v1_u8 ^ i0_u8;
return i1_u8;
}
GCC truck at O3 cannot optimize the C program (not a regression), but Clang
truck at O3 can.
Reproducer: https://godbolt.org/z/3jzG36v7r
GCC at O3:
"src":
mov eax, 5
sub eax, edi
xor eax, edi
ret
Clang at O3:
src:
mov eax, 1
ret