https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94857
Bug ID: 94857
Summary: Failure to optimize load+add+store into add on memory
when getting carry flag afterwards on x86
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
bool f(unsigned *p, unsigned x)
{
unsigned u = *p;
*p += x;
return u > *p;
}
With -O3, LLVM outputs :
f(unsigned int*, unsigned int): # @f(unsigned int*, unsigned int)
add dword ptr [rdi], esi
setb al
ret
GCC outputs :
f(unsigned int*, unsigned int):
add esi, DWORD PTR [rdi]
mov DWORD PTR [rdi], esi
setc al
ret