[Bug target/98303] New: [x86] Bad register allocation when reproducing assembly code
gabravier at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 15 21:23:52 GMT 2020
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
More information about the Gcc-bugs
mailing list