On 1/5/07, Andrew Haley <[EMAIL PROTECTED]> wrote:
This is from the gcc-help mailing list. It's mentioned there for ARM,
but it's just as bad for x86-64.
It appears that memory references to arrays aren't being hoisted out
of loops: in this test case, gcc 3.4 doesn't touch memory at all in
the loop, but 4.3pre (and 4.2, etc) does.
Here's the test case:
void foo(int *a)
{ int i;
for (i = 0; i < 1000000; i++)
a[0] += a[1];
}
gcc 3.4.5 -O2:
.L5:
leal (%rcx,%rsi), %edx
decl %eax
movl %edx, %ecx
jns .L5
gcc 4.3pre -O2:
.L2:
addl 4(%rdi), %eax
addl $1, %edx
cmpl $1000000, %edx
movl %eax, (%rdi)
jne .L2
Thoughts?
What does the code look like if you compile with -O2 -fgcse-sm?
Gr.
Steven