From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kw4lB-0001i2-5y for qemu-devel@nongnu.org; Fri, 31 Oct 2008 20:54:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kw4lA-0001hq-N3 for qemu-devel@nongnu.org; Fri, 31 Oct 2008 20:54:36 -0400 Received: from [199.232.76.173] (port=45977 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kw4lA-0001hj-FN for qemu-devel@nongnu.org; Fri, 31 Oct 2008 20:54:36 -0400 Received: from savannah.gnu.org ([199.232.41.3]:57794 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kw4lA-0003DR-V1 for qemu-devel@nongnu.org; Fri, 31 Oct 2008 20:54:37 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Kw4l9-0001Qi-2f for qemu-devel@nongnu.org; Sat, 01 Nov 2008 00:54:35 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Kw4l8-0001Qe-9E for qemu-devel@nongnu.org; Sat, 01 Nov 2008 00:54:34 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sat, 01 Nov 2008 00:54:34 +0000 Subject: [Qemu-devel] [5592] target-ppc: optimize popcntb 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 Revision: 5592 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5592 Author: aurel32 Date: 2008-11-01 00:54:33 +0000 (Sat, 01 Nov 2008) Log Message: ----------- target-ppc: optimize popcntb Suggested by Andrzej Zaborowski. Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/target-ppc/op_helper.c Modified: trunk/target-ppc/op_helper.c =================================================================== --- trunk/target-ppc/op_helper.c 2008-11-01 00:54:23 UTC (rev 5591) +++ trunk/target-ppc/op_helper.c 2008-11-01 00:54:33 UTC (rev 5592) @@ -222,25 +222,19 @@ target_ulong helper_popcntb (target_ulong val) { - uint32_t ret; - int i; - - ret = 0; - for (i = 0; i < 32; i += 8) - ret |= ctpop8((val >> i) & 0xFF) << i; - return ret; + val = (val & 0x55555555) + ((val >> 1) & 0x55555555); + val = (val & 0x33333333) + ((val >> 2) & 0x33333333); + val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); + return val; } #if defined(TARGET_PPC64) target_ulong helper_popcntb_64 (target_ulong val) { - uint64_t ret; - int i; - - ret = 0; - for (i = 0; i < 64; i += 8) - ret |= ctpop8((val >> i) & 0xFF) << i; - return ret; + val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); + val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); + val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); + return val; } #endif