https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98060
Bug ID: 98060
Summary: Failure to optimize cmp+setnb+add to cmp+sbb
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int r(unsigned v0, unsigned v1, int v2)
{
return (v0 >= v1) + v2;
}
This code, on x86, can be implemented with `cmp` followed by `sbb`. This
optimization is done by LLVM, but not by GCC.
-O3 x86 output on LLVM :
r:
mov eax, edx
cmp edi, esi
sbb eax, -1
ret
On GCC :
r:
xor eax, eax
cmp edi, esi
setnb al
add eax, edx
ret