[PATCH] Optimize ix86_expand_clrmem

Andi Kleen ak@muc.de
Thu Aug 5 14:46:00 GMT 2004

Jakub Jelinek <jakub@redhat.com> writes:

> Hi!
> For say:
> void foo (char *p, long *q)
> {
>   __builtin_memset (p, 0, 7);
>   __builtin_memset (q, 0, 9);
> }

I also noticed that a bigger constant size aligned memset is often 
unrolled far too much on Opteron.

And memset behaves different depending on if it is called with 0 
or a different value argument.


void f(unsigned long *foo) 
        __builtin_memset(foo, 0xff, 9*8); 


       movq    $-1, %rax
        movq    %rax, (%rdi)
        movq    %rax, 8(%rdi)
        movq    %rax, 16(%rdi)
        movq    %rax, 24(%rdi)
        movq    %rax, 32(%rdi)
        movq    %rax, 40(%rdi)
        movq    %rax, 48(%rdi)
        movq    %rax, 56(%rdi)
        movq    %rax, 64(%rdi)

but when I change the value to 0 it generates a call to a memset.


More information about the Gcc-patches mailing list