All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, tglx@tglx.de,
	hpa@zytor.com, torvalds@linux-foundation.org
Subject: Re: [PATCH] x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy
Date: Fri, 02 Oct 2009 21:19:18 +0200	[thread overview]
Message-ID: <87bpkpbo3t.fsf@basil.nowhere.org> (raw)
In-Reply-To: <20090928113433.5e9b8ea7@infradead.org> (Arjan van de Ven's message of "Mon, 28 Sep 2009 11:34:33 +0200")

Arjan van de Ven <arjan@infradead.org> writes:

> From ebb81aab0c3df19771ebc0eec1261ae314ddc0af Mon Sep 17 00:00:00 2001
> From: Arjan van de Ven <arjan@linux.intel.com>
> Date: Mon, 28 Sep 2009 11:21:32 +0200
> Subject: [PATCH] x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy
>
> GCC provides reasonable memset/memcpy functions itself, with __builtin_memset
> and __builtin_memcpy. For the "unknown" cases, it'll fall back to our
> current existing functions, but for fixed size versions it'll inline
> something smart. Quite often that will be the same as we have now,
> but sometimes it can do something smarter (for example, if the code
> then sets the first member of a struct, it can do a shorter memset).
>
> In addition, and this is more important, gcc knows which registers and
> such are not clobbered (while for our asm version it pretty much
> acts like a compiler barrier), so for various cases it can avoid reloading
> values.
>
> The effect on codesize is shown below on my typical laptop .config:
>
>    text	   data	    bss	    dec	    hex	filename
> 5605675	2041100	6525148	14171923	 d83f13	vmlinux.before
> 5595849	2041668	6525148	14162665	 d81ae9	vmlinux.after

I tried this some time ago, but it it generates bad code on some 
gcc 3 versions.

You really need to test such kind of changes on a wide variety
of compilers, not assuming everyone uses the same version as you.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

  parent reply	other threads:[~2009-10-02 19:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28  9:34 [PATCH] x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy Arjan van de Ven
2009-09-28 12:21 ` Arjan van de Ven
2009-09-28 23:47   ` [tip:x86/asm] " tip-bot for Arjan van de Ven
2009-09-29 12:44 ` [PATCH] " Arnd Bergmann
2009-09-29 12:53   ` Arjan van de Ven
2009-09-29 15:32   ` H. Peter Anvin
2009-10-02 19:19 ` Andi Kleen [this message]
2009-10-02 20:04   ` H. Peter Anvin
2009-10-02 20:12     ` Andi Kleen

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=87bpkpbo3t.fsf@basil.nowhere.org \
    --to=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@tglx.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.