[Bug c/88959] New: Unnecessary xor before bsf/tzcnt
bugzilla@poradnik-webmastera.com
gcc-bugzilla@gcc.gnu.org
Mon Jan 21 18:23:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88959
Bug ID: 88959
Summary: Unnecessary xor before bsf/tzcnt
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bugzilla@poradnik-webmastera.com
Target Milestone: ---
[code]
int test(int x)
{
return __builtin_ctz(x);
}
[/code]
gcc 4.9.1 with -O3 produces this:
[asm]
test(int):
rep bsf eax, edi
ret
[/asm]
And this with -O3 -mbmi:
[asm]
test(int):
tzcnt eax, edi
ret
[/asm]
gcc 4.9.2 and newer (including gcc 9) produces this for both cases:
[asm]
test(int):
xor eax, eax
rep bsf eax, edi
ret
[/asm]
[asm]
test(int):
xor eax, eax
tzcnt eax, edi
ret
[/asm]
This extra xor instruction is not needed here.
More information about the Gcc-bugs
mailing list