Check vl first
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
Select element-wise between vs2 and integer scalar rs1 using v0 selection mask bits, writing vd.
VMERGE.VXM is a RISC-V V vector integer merge instruction. v0.mask[i]=0 selects vs2[i], and v0.mask[i]=1 selects the SEW-width scalar value formed from x[rs1] by the .vx scalar rule.
Starts from OP-V encoding fields, then shows how VMERGE uses v0 as selection data: bit 0 selects vs2, bit 1 selects the second source, and every body element is written.
vmerge.vxm uses OP-V encoding. The animation places fixed fields, register fields, vm, and the rs1 field in one encoding strip.
This animation shows only ISA-visible relationships from the official V extension: OP-V field decode, active-element reads, SEW-width integer v0-selected merge, v0 selection data, and vd writeback. It does not model pipelines, caches, or timing.
VMERGE.VXM treats v0 as selection-mask data: 0 selects vs2 and 1 selects integer scalar rs1. It writes selected results for body elements within the current vl; it is not ordinary masked execution.
When reading VMERGE.VXM, 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 «vmerge.vxm v8, v4, a1, v0».
Understand this scenario with real code like «vmerge.vxm v8, v4, a1, v0».
v0.mask[i]=1 selects integer scalar rs1; v0.mask[i]=0 selects vs2[i].
No. VMERGE uses v0 as a selection input and takes each body element from one of two sources; ordinary masked instructions use v0.t to decide whether an element participates.