This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [4.3] Invalid code or invalid optimisation?
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- Cc: Andrew Haley <aph at redhat dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 04 Jun 2009 11:00:38 +0100
- Subject: Re: [4.3] Invalid code or invalid optimisation?
- References: <4A2728AA.3010205@gmail.com> <4A27857D.50708@redhat.com> <4A279526.8090905@gmail.com>
Dave Korn wrote:
> Andrew Haley wrote:
>> Volatile stores only block other
>> volatile stores: they don't block *all* stores. If you really want a complete
>> memory barrier, which in a mutex you surely do, then you're going to have to
>> clobber memory.
>
> Ah. That suggests that HEAD is in fact _missing_ an optimisation that 4.3
> gets right. Maybe I should file a PR after all.
It also suggests that the register motion is fairly gratuitous, I think.
movl %eax, -12(%ebp) # tmp79, ret
movl -12(%ebp), %eax # ret, D.2120
Given that ret is a local variable that goes immediately out of scope, I
can't see any reason to update the stack slot. I can prevent this happening
by declaring the temporary as 'register __typeof (*t) ret __asm ("%eax");' but
doesn't this mean we're missing a trick here between some combination of
regalloc, copyprop and dead-store elimination?
cheers,
DaveK