[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 57/64] target-s390x: Avoid a loop for popcnt
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v4 57/64] target-s390x: Avoid a loop for popcnt |
Date: |
Wed, 23 Nov 2016 14:01:54 +0100 |
Signed-off-by: Richard Henderson <address@hidden>
---
target-s390x/int_helper.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index 5bc470b..f26f36a 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -137,14 +137,11 @@ uint64_t HELPER(cvd)(int32_t reg)
return dec;
}
-uint64_t HELPER(popcnt)(uint64_t r2)
+uint64_t HELPER(popcnt)(uint64_t val)
{
- uint64_t ret = 0;
- int i;
-
- for (i = 0; i < 64; i += 8) {
- uint64_t t = ctpop32((r2 >> i) & 0xff);
- ret |= t << i;
- }
- return ret;
+ /* Note that we don't fold past bytes. */
+ val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
+ val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
+ val = (val + (val >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
+ return val;
}
--
2.7.4
- [Qemu-devel] [PATCH v4 51/64] target-arm: Use clrsb helper, (continued)
- [Qemu-devel] [PATCH v4 51/64] target-arm: Use clrsb helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 49/64] tcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 48/64] tcg/i386: Handle ctz and clz opcodes, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 50/64] tcg: Add helpers for clrsb, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 52/64] target-tricore: Use clrsb helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 53/64] target-xtensa: Use clrsb helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 54/64] tcg: Add opcode for ctpop, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 55/64] target-alpha: Use ctpop helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 56/64] target-ppc: Use ctpop helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 57/64] target-s390x: Avoid a loop for popcnt,
Richard Henderson <=
- [Qemu-devel] [PATCH v4 58/64] target-sparc: Use ctpop helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 59/64] target-tilegx: Use ctpop helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 60/64] target-i386: Use ctpop helper, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 61/64] qemu/host-utils.h: Reduce the operation count in the fallback ctpop, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 63/64] tcg/ppc: Handle ctpop opcode, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 62/64] tcg: Use ctpop to generate ctz if needed, Richard Henderson, 2016/11/23
- [Qemu-devel] [PATCH v4 64/64] tcg/i386: Handle ctpop opcode, Richard Henderson, 2016/11/23
- Re: [Qemu-devel] [PATCH v4 00/64] tcg 2.9 patch queue, no-reply, 2016/11/29