Check vl first
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
Pack vs2 elements selected by the vs1 mask into contiguous positions starting at vd[0].
VCOMPRESS.VM uses the explicit vs1 mask to select elements from vs2 and writes the selected elements contiguously from vd[0] in original order; it is encoded as an unmasked instruction, and destination elements after the packed result are tail elements.
Starts from OP-V encoding fields, then shows how VCOMPRESS uses the explicit vs1 selection mask to pack selected vs2 elements in order starting at vd[0].
vcompress.vm uses OP-V encoding. The animation places fixed fields, register fields, vm, and the vs1 field in one encoding strip.
This animation shows only ISA-visible relationships from the official V extension: OP-V field decode, active-element reads, element-index/packing/select/move rearrangement integer mask compress, boundary/selection rules, and vd writeback. It does not model pipelines, caches, or timing.
vcompress.vm performs stable compaction of source lanes with vs1=1 within vl: the first selected element writes vd[0], the second writes vd[1], and so on.
When reading VCOMPRESS.VM, do not stop at the mnemonic. Official V-extension semantics also depend on the current vl, vtype, and mask state. The suffix and operand form determine whether sources are vector, scalar, or immediate values.
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
The current vtype supplies SEW, LMUL, tail policy, and mask policy; these affect element width, register-group size, and inactive/tail destination elements.
For ordinary vector instructions with vm, vm=0 uses v0 as the execution mask and vm=1 is unmasked. A few forms such as VMERGE use v0 as data-selection input.
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vmsgt.vi v0, v8, 10 vcompress.vm v12, v8, v0».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vmsgt.vi v0, v8, 10 vcompress.vm v12, v8, v0».
No. Unselected source elements are not packed into the contiguous result; destination elements after the packed result are tail elements governed by vtype.vta.