VCPOP.M

RISC-V VCPOP.M Instruction Details

Instruction ManualR-type

Count 1 bits in the active mask elements and write the scalar result to rd

Instruction Syntax

vcpop.m rd, vs2, vm
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
VVector Mask Operations

Instruction Behavior

VCPOP.M counts active set bits in mask source vs2 and writes the count to integer register rd. The execution mask can restrict which elements participate.

Quick Understanding & Search Notes

VCPOP.M is an RVV mask-to-scalar instruction: the result is written to integer register rd, not a vector register.

The source is viewed as a mask register; participation is still controlled by vl and the optional execution mask.
The operation applies only to active elements within vl; inactive and tail elements follow the current vma/vta policy.
Except for dedicated mask forms, vm=0 uses v0 as the execution mask and vm=1 is unmasked.

Common Usage Scenarios

Loop Condition

Understand this scenario with real code like «vcpop.m rd, vs2».

Mask Density

Understand this scenario with real code like «vcpop.m rd, vs2».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

The official mnemonic is vcpop.m; vpopc.m is only an older alias.
A nonzero vstart raises an illegal-instruction exception.
The source is mask register bits, not SEW-width data elements.

FAQ

Where is the result written?

It is written to scalar integer register rd. VCPOP.M writes a count; VFIRST.M writes the first set element index or -1.