https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98303
Bug ID: 98303 Summary: [x86] Bad register allocation when reproducing assembly code 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 f1(int n) { while (n >= 64) n -= 64; return n; } On x86, with -O3, this generates : f1(int): mov eax, edi and eax, 63 cmp edi, 63 cmovle eax, edi ret This code : int f2(int n) { return (n <= 63) ? n : (n & 63); } which behaves equivalently, seems to result in poorer generated code : f2(int): mov edx, edi mov eax, edi and edx, 63 cmp edi, 63 cmovg eax, edx ret