[Bug target/98977] New: [x86] Failure to optimize consecutive sub flags usage
gabravier at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 5 14:20:19 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98977
Bug ID: 98977
Summary: [x86] Failure to optimize consecutive sub flags usage
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: ---
extern bool z, c;
uint8_t f(uint8_t dest, uint8_t src)
{
u8 res = dest - src;
z = !res;
c = src > dest;
return res;
}
With -O3, LLVM outputs this:
f(unsigned char, unsigned char):
mov eax, edi
sub al, sil
sete byte ptr [rip + z]
setb byte ptr [rip + c]
ret
GCC outputs this:
f(unsigned char, unsigned char):
mov eax, edi
sub al, sil
sete BYTE PTR z[rip]
cmp dil, sil
setb BYTE PTR c[rip]
ret
It seems desirable to eliminate the `cmp`, unless there's some weird flag stall
thing I'm not aware of.
More information about the Gcc-bugs
mailing list