mirror of
https://github.com/qemu/qemu.git
synced 2025-01-21 21:13:25 +08:00
target-s390x: Avoid a loop for popcnt
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
7977000220
commit
250a87d556
@ -137,14 +137,11 @@ uint64_t HELPER(cvd)(int32_t reg)
|
|||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t HELPER(popcnt)(uint64_t r2)
|
uint64_t HELPER(popcnt)(uint64_t val)
|
||||||
{
|
{
|
||||||
uint64_t ret = 0;
|
/* Note that we don't fold past bytes. */
|
||||||
int i;
|
val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
|
||||||
|
val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
|
||||||
for (i = 0; i < 64; i += 8) {
|
val = (val + (val >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
|
||||||
uint64_t t = ctpop32((r2 >> i) & 0xff);
|
return val;
|
||||||
ret |= t << i;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user