From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KwHZ3-00042C-7J for qemu-devel@nongnu.org; Sat, 01 Nov 2008 10:34:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KwHZ0-00041w-Om for qemu-devel@nongnu.org; Sat, 01 Nov 2008 10:34:55 -0400 Received: from [199.232.76.173] (port=59378 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KwHZ0-00041t-Jy for qemu-devel@nongnu.org; Sat, 01 Nov 2008 10:34:54 -0400 Received: from wf-out-1314.google.com ([209.85.200.175]:24443) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KwHZ0-0004Vn-Io for qemu-devel@nongnu.org; Sat, 01 Nov 2008 10:34:54 -0400 Received: by wf-out-1314.google.com with SMTP id 27so1715217wfd.4 for ; Sat, 01 Nov 2008 07:34:53 -0700 (PDT) Message-ID: <761ea48b0811010734s5d85f731v878752ee5af74673@mail.gmail.com> Date: Sat, 1 Nov 2008 15:34:53 +0100 From: "Laurent Desnogues" Subject: Re: [Qemu-devel] [5592] target-ppc: optimize popcntb In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <761ea48b0811010529w50904850h41028a811609fefc@mail.gmail.com> <761ea48b0811010535t51088dd5n8362b0b34db48a0@mail.gmail.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Sat, Nov 1, 2008 at 2:57 PM, andrzej zaborowski wrote: > > On ppc host there might be a builtin for it, on the x86 Xeon cpus with > SSE4 there's also a bitcounting instruction but this approach is > actually faster than transferring the number to the MMX register, > running the instruction and copying the value back. In the benchmarks > I've seen the speed is comparable with table lookup on x86 and -O3. Bit tricks are always very sensitive. BTW I would not trust any benchmark that run them in loop for obvious reasons :-) For those who like that kind of thing, here are some nice refs: - Knuth: http://www-cs-faculty.stanford.edu/~uno/fasc1a.ps.gz - Anderson: http://www-graphics.stanford.edu/~seander/bithacks.html - Arndt: http://www.jjj.de/bitwizardry/bitwizardrypage.html Many of these tricks are known or obvious, but it's good reading anyway, especially for qemu target and back-end writers. Laurent