https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97873
Bug ID: 97873 Summary: Failure to optimize abs optimally (at least one useless instruction on x86) Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- int abs(int x) { return (x < 0) ? -x : x; } For x86 -O3, LLVM outputs this: abs: mov eax, edi neg eax cmovl eax, edi ret GCC outputs this: abs: mov eax, edi neg eax cmp eax, edi cmovl eax, edi ret