This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: basic asm and memory clobbers
- From: Andrew Haley <aph at redhat dot com>
- To: David Wohlferd <dw at LimeGreenSocks dot com>, Jeff Law <law at redhat dot com>, Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, rth at gcc dot gnu dot org, pinskia at gcc dot gnu dot org, Sandra Loosemore <sandra at codesourcery dot com>
- Date: Fri, 20 Nov 2015 10:17:28 +0000
- Subject: Re: basic asm and memory clobbers
- Authentication-results: sourceware.org; auth=none
- References: <563FE459 dot 3000003 at LimeGreenSocks dot com> <20151109093229 dot GA5260 at gate dot crashing dot org> <56493010 dot 9070707 at LimeGreenSocks dot com> <564A4AA5 dot 1080706 at redhat dot com> <564AC155 dot 4040601 at LimeGreenSocks dot com> <564B9CB1 dot 1060001 at redhat dot com> <564E762B dot 6070705 at LimeGreenSocks dot com>
On 20/11/15 01:23, David Wohlferd wrote:
> I tried to picture the most basic case I can think of that uses
> something clobber-able:
>
> for (int x=0; x < 1000; x++)
> asm("#stuff");
>
> This generates very simple and highly performant code:
>
> movl $1000, %eax
> .L2:
> #stuff
> subl $1, %eax
> jne .L2
>
> Using extended asm to simulate the clobberall gives:
>
> movl $1000, 44(%rsp)
> .L2:
> #stuff
> subl $1, 44(%rsp)
> jne .L2
>
> It allocates an extra 4 bytes, and changed everything to memory accesses
> instead of using a register.
Can you show us your code? I get
xx:
movl $1000, %eax
.L2:
#stuff
subl $1, %eax
jne .L2
rep; ret
for
void xx() {
for (int x=0; x < 1000; x++)
asm volatile("#stuff" : : : "memory");
}
What you're describing looks like a bug: x doesn't have its address
taken.
Andrew.