Commit d600cbed0fe8fceec04500824f638dfe4996c653
1 parent
ef7c4d4675
Exists in
master
and in
4 other branches
sparc: Use hweight64() in popc emulation.
Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 4 additions and 11 deletions Side-by-side Diff
arch/sparc/kernel/unaligned_64.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | #include <linux/bitops.h> |
23 | 23 | #include <linux/perf_event.h> |
24 | 24 | #include <linux/ratelimit.h> |
25 | +#include <linux/bitops.h> | |
25 | 26 | #include <asm/fpumacro.h> |
26 | 27 | |
27 | 28 | enum direction { |
28 | 29 | |
29 | 30 | |
... | ... | @@ -373,16 +374,11 @@ |
373 | 374 | } |
374 | 375 | } |
375 | 376 | |
376 | -static char popc_helper[] = { | |
377 | -0, 1, 1, 2, 1, 2, 2, 3, | |
378 | -1, 2, 2, 3, 2, 3, 3, 4, | |
379 | -}; | |
380 | - | |
381 | 377 | int handle_popc(u32 insn, struct pt_regs *regs) |
382 | 378 | { |
383 | - u64 value; | |
384 | - int ret, i, rd = ((insn >> 25) & 0x1f); | |
385 | 379 | int from_kernel = (regs->tstate & TSTATE_PRIV) != 0; |
380 | + int ret, rd = ((insn >> 25) & 0x1f); | |
381 | + u64 value; | |
386 | 382 | |
387 | 383 | perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0); |
388 | 384 | if (insn & 0x2000) { |
... | ... | @@ -392,10 +388,7 @@ |
392 | 388 | maybe_flush_windows(0, insn & 0x1f, rd, from_kernel); |
393 | 389 | value = fetch_reg(insn & 0x1f, regs); |
394 | 390 | } |
395 | - for (ret = 0, i = 0; i < 16; i++) { | |
396 | - ret += popc_helper[value & 0xf]; | |
397 | - value >>= 4; | |
398 | - } | |
391 | + ret = hweight64(value); | |
399 | 392 | if (rd < 16) { |
400 | 393 | if (rd) |
401 | 394 | regs->u_regs[rd] = ret; |