[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 57/65] target-s390x: Avoid a loop for popcnt
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 57/65] target-s390x: Avoid a loop for popcnt |
Date: |
Fri, 23 Dec 2016 20:00:34 -0800 |
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.9.3
- [Qemu-devel] [PATCH 45/65] tcg/i386: Fuly convert tcg_target_op_def, (continued)
- [Qemu-devel] [PATCH 45/65] tcg/i386: Fuly convert tcg_target_op_def, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 47/65] tcg/i386: Allow bmi2 shiftx to have non-matching operands, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 53/65] target-xtensa: Use clrsb helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 50/65] tcg: Add helpers for clrsb, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 56/65] target-ppc: Use ctpop helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 59/65] target-tilegx: Use ctpop helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 46/65] tcg/i386: Hoist common arguments in tcg_out_op, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 48/65] tcg/i386: Handle ctz and clz opcodes, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 51/65] target-arm: Use clrsb helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 55/65] target-alpha: Use ctpop helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 57/65] target-s390x: Avoid a loop for popcnt,
Richard Henderson <=
- [Qemu-devel] [PATCH 54/65] tcg: Add opcode for ctpop, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 61/65] qemu/host-utils.h: Reduce the operation count in the fallback ctpop, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 60/65] target-i386: Use ctpop helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 49/65] tcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 58/65] target-sparc: Use ctpop helper, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 65/65] tcg/i386: Handle ctpop opcode, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 62/65] tests: New test-bitcnt, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 63/65] tcg: Use ctpop to generate ctz if needed, Richard Henderson, 2016/12/23
- [Qemu-devel] [PATCH 64/65] tcg/ppc: Handle ctpop opcode, Richard Henderson, 2016/12/23