This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Really, really const
Gabriel Dos Reis writes:
> Andrew Haley <aph@redhat.com> writes:
>
> | So, I wonder why gcc reads the memory twice.
>
> Maybe is it because GCC is treating a as a pointer of type "const int*"
> instead of an array of "const int"? That early decay might be
> pessimizing.
Maybe. I just tried 3.2.2 and it doesn't read the memory twice:
foo:
pushl %ebx
subl $8, %esp
movl a, %ebx
sall $1, %ebx
call f
addl $8, %esp
movl %ebx, %eax
popl %ebx
ret
but mainline does:
foo:
pushl %ebx
subl $8, %esp
movl a, %ebx
call f
movl a, %eax
addl $8, %esp
addl %eax, %ebx
movl %ebx, %eax
popl %ebx
ret
So this looks like a regression.
Andrew.