Check vl first
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
Merge vs2[i] with f[rs1] under v0: mask 1 selects f[rs1], mask 0 selects vs2[i].
VFMERGE.VFM merges a floating-point scalar with vector elements. For each element, v0.mask[i]=1 selects f[rs1] for vd[i], while v0.mask[i]=0 selects vs2[i]; v0 is the selection mask rather than a normal execution mask.
VFMERGE.VFM is conditional selection, not arithmetic. The common mistake is reversing the selection direction: mask bit 1 selects the FP scalar, and mask bit 0 selects the vs2 element.
When reading VFMERGE.VFM, 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 vfmerge.vfm v1, v2, ft0, v0 # v0[i] ? ft0 : v2[i]».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vfmerge.vfm v1, v2, ft0, v0 # v0[i] ? ft0 : v2[i]».
It selects floating-point scalar f[rs1]; mask bit 0 selects vs2[i].