From: Linus Torvalds <torvalds@linux-foundation.org>
To: Andy Lutomirski <luto@kernel.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Borislav Petkov <bp@alien8.de>,
Rasmus Villemoes <mail@rasmusvillemoes.dk>,
x86-ml <x86@kernel.org>, Josh Poimboeuf <jpoimboe@redhat.com>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Improve memset
Date: Mon, 16 Sep 2019 16:26:20 -0700 [thread overview]
Message-ID: <CAHk-=wiw6q1hk7QHP+8M6H9zRDj-yJ8p-KyhQS9gTJA8NopYkA@mail.gmail.com> (raw)
In-Reply-To: <CALCETrUkBCh8h66pJCJtDGNtvhmVaNuppddsBLkQiHFoNrW-xg@mail.gmail.com>
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
next prev parent reply other threads:[~2019-09-16 23:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 7:22 [RFC] Improve memset Borislav Petkov
2019-09-13 7:35 ` Ingo Molnar
2019-09-13 7:50 ` Borislav Petkov
2019-09-13 8:51 ` Rasmus Villemoes
2019-09-13 9:00 ` Linus Torvalds
2019-09-13 9:18 ` Rasmus Villemoes
2019-09-13 10:42 ` Borislav Petkov
2019-09-13 16:36 ` Borislav Petkov
2019-09-16 9:18 ` Rasmus Villemoes
2019-09-16 17:25 ` Linus Torvalds
2019-09-16 17:40 ` Andy Lutomirski
2019-09-16 21:29 ` Linus Torvalds
2019-09-16 23:13 ` Andy Lutomirski
2019-09-16 23:26 ` Linus Torvalds [this message]
2019-09-17 8:15 ` Borislav Petkov
2019-09-17 10:55 ` David Laight
2019-09-17 20:10 ` Josh Poimboeuf
2019-09-17 20:45 ` Linus Torvalds
2019-09-19 12:55 ` Borislav Petkov
2019-09-19 12:49 ` Borislav Petkov
2019-09-14 9:29 Alexey Dobriyan
2019-09-14 11:39 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHk-=wiw6q1hk7QHP+8M6H9zRDj-yJ8p-KyhQS9gTJA8NopYkA@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=bp@alien8.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=luto@kernel.org \
--cc=mail@rasmusvillemoes.dk \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).