aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vcpop_m.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/vcpop_m.h')
-rw-r--r--riscv/insns/vcpop_m.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/riscv/insns/vcpop_m.h b/riscv/insns/vcpop_m.h
index f909311..26a1276 100644
--- a/riscv/insns/vcpop_m.h
+++ b/riscv/insns/vcpop_m.h
@@ -6,15 +6,7 @@ reg_t rs2_num = insn.rs2();
require(P.VU.vstart->read() == 0);
reg_t popcount = 0;
for (reg_t i=P.VU.vstart->read(); i<vl; ++i) {
- const int midx = i / 32;
- const int mpos = i % 32;
-
- bool vs2_lsb = ((P.VU.elt<uint32_t>(rs2_num, midx ) >> mpos) & 0x1) == 1;
- if (insn.v_vm() == 1) {
- popcount += vs2_lsb;
- } else {
- bool do_mask = (P.VU.elt<uint32_t>(0, midx) >> mpos) & 0x1;
- popcount += (vs2_lsb && do_mask);
- }
+ bool vs2_bit = P.VU.mask_elt(rs2_num, i);
+ popcount += vs2_bit && (insn.v_vm() || P.VU.mask_elt(0, i));
}
WRITE_RD(popcount);