This is the mail archive of the gcc-patches@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: [PATCH] Optimize ix86_expand_clrmem


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.

e.g. 

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

generates

       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)
        ret

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

-Andi



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