target-i386: SSE4.2: use clz32/ctz32 instead of reinventing the wheel
Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
83f7dc28ca
commit
c334a3880c
|
@ -20,6 +20,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
#include "qemu/host-utils.h"
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
#include "exec/softmmu_exec.h"
|
#include "exec/softmmu_exec.h"
|
||||||
|
|
|
@ -2064,34 +2064,6 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s,
|
||||||
return res;
|
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,
|
void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
|
||||||
uint32_t ctrl)
|
uint32_t ctrl)
|
||||||
{
|
{
|
||||||
|
@ -2100,7 +2072,7 @@ void glue(helper_pcmpestri, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
|
||||||
pcmp_elen(env, R_EAX, ctrl));
|
pcmp_elen(env, R_EAX, ctrl));
|
||||||
|
|
||||||
if (res) {
|
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 {
|
} else {
|
||||||
env->regs[R_ECX] = 16 >> (ctrl & (1 << 0));
|
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));
|
pcmp_ilen(d, ctrl));
|
||||||
|
|
||||||
if (res) {
|
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 {
|
} else {
|
||||||
env->regs[R_ECX] = 16 >> (ctrl & (1 << 0));
|
env->regs[R_ECX] = 16 >> (ctrl & (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue