From patchwork Tue Mar 26 19:01:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 231518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D41802C007C for ; Wed, 27 Mar 2013 06:02:59 +1100 (EST) Received: from localhost ([::1]:51211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKZ97-0005RX-01 for incoming@patchwork.ozlabs.org; Tue, 26 Mar 2013 15:02:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKZ8F-0004u4-IY for qemu-devel@nongnu.org; Tue, 26 Mar 2013 15:02:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKZ8A-0005rb-IL for qemu-devel@nongnu.org; Tue, 26 Mar 2013 15:02:03 -0400 Received: from hall.aurel32.net ([2001:470:1f15:c4f::1]:49216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKZ8A-0005oB-9y for qemu-devel@nongnu.org; Tue, 26 Mar 2013 15:01:58 -0400 Received: from [2001:470:d4ed:0:ea11:32ff:fea1:831a] (helo=ohm.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UKZ7z-0007z1-Nj; Tue, 26 Mar 2013 20:01:48 +0100 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.80) (envelope-from ) id 1UKZ7y-0002SZ-2H; Tue, 26 Mar 2013 20:01:46 +0100 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Tue, 26 Mar 2013 20:01:42 +0100 Message-Id: <1364324502-9124-11-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364324502-9124-1-git-send-email-aurelien@aurel32.net> References: <1364324502-9124-1-git-send-email-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1f15:c4f::1 Cc: Aurelien Jarno Subject: [Qemu-devel] [PATCH 10/10] target-i386: SSE4.2: use clz32/ctz32 instead of reinventing the wheel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Aurelien Jarno Reviewed-by: Richard Henderson --- target-i386/fpu_helper.c | 1 + target-i386/ops_sse.h | 32 ++------------------------------ 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c index 44f3d27..29a8fb6 100644 --- a/target-i386/fpu_helper.c +++ b/target-i386/fpu_helper.c @@ -20,6 +20,7 @@ #include #include "cpu.h" #include "helper.h" +#include "qemu/host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "exec/softmmu_exec.h" diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h index a0bac07..a11dba1 100644 --- a/target-i386/ops_sse.h +++ b/target-i386/ops_sse.h @@ -2064,34 +2064,6 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s, return res; } -static inline int rffs1(unsigned int val) -{ - int ret = 1, hi; - - for (hi = sizeof(val) * 4; hi; hi /= 2) { - if (val >> hi) { - val >>= hi; - ret += hi; - } - } - - return ret; -} - -static inline int ffs1(unsigned int val) -{ - int ret = 1, hi; - - for (hi = sizeof(val) * 4; hi; hi /= 2) { - if (val << hi) { - val <<= hi; - ret += hi; - } - } - - return ret; -} - void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, uint32_t ctrl) { @@ -2100,7 +2072,7 @@ void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, pcmp_elen(env, R_EAX, ctrl)); if (res) { - env->regs[R_ECX] = (ctrl & (1 << 6)) ? rffs1(res) - 1 : 32 - ffs1(res); + env->regs[R_ECX] = (ctrl & (1 << 6)) ? 31 - clz32(res) : ctz32(res); } else { env->regs[R_ECX] = 16 >> (ctrl & (1 << 0)); } @@ -2138,7 +2110,7 @@ void glue(helper_pcmpistri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s, pcmp_ilen(d, ctrl)); if (res) { - env->regs[R_ECX] = (ctrl & (1 << 6)) ? rffs1(res) - 1 : 32 - ffs1(res); + env->regs[R_ECX] = (ctrl & (1 << 6)) ? 31 - clz32(res) : ctz32(res); } else { env->regs[R_ECX] = 16 >> (ctrl & (1 << 0)); }