From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Illh6-0007pw-VR for qemu-devel@nongnu.org; Sat, 27 Oct 2007 09:27:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Illh4-0007p7-UT for qemu-devel@nongnu.org; Sat, 27 Oct 2007 09:27:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Illh4-0007p1-IF for qemu-devel@nongnu.org; Sat, 27 Oct 2007 09:27:14 -0400 Received: from moutng.kundenserver.de ([212.227.126.174]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Illh4-0002s1-8u for qemu-devel@nongnu.org; Sat, 27 Oct 2007 09:27:14 -0400 Received: from skua.int.moresnet.net ([10.0.255.247]) by panic.int.moresnet.net with esmtp (Exim 4.63) (envelope-from ) id 1Illgs-0003rP-1V for qemu-devel@nongnu.org; Sat, 27 Oct 2007 15:27:11 +0200 Message-ID: <47233CA5.3070509@brainaid.de> Date: Sat, 27 Oct 2007 15:27:01 +0200 From: "Christian \"Eddie\" Dost" MIME-Version: 1.0 Subject: Re: [Qemu-devel] Mips 64 emulation not compiling References: <1193222474.16781.236.camel@rapid> <20071027111939.GH29176@networkno.de> <1193487891.16781.280.camel@rapid> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 The sparc64 popc works in O(lg(n)), the "optimized" code below work in O(n). Could be better to generalize the sparc64 code, like this: static always_inline int ctpop32 (uint32_t val) { uint32_t i; i = (val & 0x55555555) + ((val >> 1) & 0x55555555); i = (i & 0x33333333) + ((i >> 2) & 0x33333333); i = (i & 0x0f0f0f0f) + ((i >> 4) & 0x0f0f0f0f); i = (i & 0x00ff00ff) + ((i >> 8) & 0x00ff00ff); i = (i & 0x0000ffff) + ((i >> 16) & 0x0000ffff); return i; } For the 64 bit version see target-sparc/op_helper.c Best regards, Eddie Blue Swirl wrote: > On 10/27/07, J. Mayer wrote: >> I also got optimized versions of bit population count which could also >> be shared: >> static always_inline int ctpop32 (uint32_t val) >> { >> int i; >> >> for (i = 0; val != 0; i++) >> val = val ^ (val - 1); >> >> return i; >> } >> >> If you prefer, I can add those shared functions (ctz32, ctz64, cto32, >> cto64, ctpop32, ctpop64) later, as they do not seem as widely used as >> clxxx functions. > > This would be interesting for Sparc64. Could you compare your version > to do_popc() in target-sparc/op_helper.c? > > -- ___________________________________________________brainaid_____________ Eddie C. Dost Rue de la Chapelle 51 phone +32 87 788817 B-4850 Moresnet fax +32 87 788818 ecd@brainaid.de Belgium cell +49 172 9312808