lkml.org 
[lkml]   [2019]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC] Improve memset
On Mon, Sep 16, 2019 at 4:14 PM Andy Lutomirski <luto@kernel.org> wrote:
>
> Well, when I wrote this email, I *thought* it was inlining the
> 'memset' function, but maybe I just can't read gcc's output today.

Not having your compiler, it's also possible that it works for you,
but just doesn't work for me.

> It seems like gcc is maybe smart enough to occasionally optimize
> memset just because it's called 'memset'. This generates good code:

Yup, that does the rigth thing for me and ignores the definition of
memset() in favor of the built-in one.

However, at least part of this discussion started because of the
reverse problem (turning a couple of assignments into memset), and the
suggestion that we might be able to use -ffreestanding together with

#define memset __builtin_memset

and then your nice code generation goes away, because the magical
treatment of memset goes away. I get

one_word:
xorl %eax, %eax
ret

not_one_word:
movq %rsi, %rdx
xorl %esi, %esi
jmp memset

despite having that "inline void *memset()" definition.

Linus

\
 
 \ /
  Last update: 2019-09-17 01:27    [W:0.069 / U:1.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site