http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46763
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> 2010-12-02
11:03:00 UTC ---
Small testcase for the global load/store issue:
int g;
extern int bar(int);
void foo(int n)
{
int i;
for (i = 0; i < n; i++)
{
if (g)
{
g++;
g = bar(i);
}
else
g = i;
}
}
Trunk at -O3 does not optimize stores to g (at -O2, it also loads g on each
iteration):
.L3:
movl %ebx, g(%rip)
movl %ebx, %eax
addl $1, %ebx
cmpl %ebp, %ebx
je .L1
.L5:
testl %eax, %eax
je .L3
addl $1, %eax
movl %ebx, %edi
addl $1, %ebx
movl %eax, g(%rip)
call bar
cmpl %ebp, %ebx
movl %eax, g(%rip)
jne .L5