This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic asm and memory clobbers


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]