Home/Instructions/VMSGTU-VX
VMSGTU.VX

RISC-V VMSGTU.VX Instruction Details

Instruction ManualOPIVX

VMSGTU.VX performs element-wise unsigned greater-than scalar comparison and writes active-element Boolean results to the destination mask.

Instruction Syntax

vmsgtu.vx vd, vs2, rs1, vm
Operand Breakdown
vd: mask destination register, with one Boolean result bit per element.
vs2/vs1 or scalar source: compared at the current SEW.
vm: vm=0 uses v0 to restrict participating elements, and vm=1 is unmasked.
VVector IntegerCompare

Instruction Behavior

VMSGTU.VX is a RISC-V V-extension vector-scalar integer predicate-generation instruction. Within the current vl body elements, it compares vs2[i] with x[rs1]; vm=1 lets all body elements participate, while vm=0 processes only elements selected by v0.t. The result is written to vd in mask-register layout, one bit per element index; integer compares do not set floating-point exception flags.

VMSGTU.VX Decode And Execute Animation

Starts from OP-V encoding, then shows how unsigned integer greater than with scalar comparison reads active elements and produces a one-bit-per-element predicate mask.

Instruction input
vmsgtu.vx
V-format integer compare encoding
31..26
funct6
011110
25
vm
1
24..20
vs2
v8
19..15
rs1
x11
14..12
funct3
100
11..7
vd
v0
6..0
opcode
1010111
lane
0
1
2
3
4
5
6
7
v8
3
2
7
7
0
12
5
9
>u
>u
>u
>u
>u
>u
>u
>u
>u
x11
7
7
7
7
7
7
7
7
active
1
1
1
1
1
1
1
1
v0
-
-
-
-
-
-
-
-

This animation shows only the ISA-visible comparison, execution-mask, and destination-mask writeback relationship; inactive and tail elements are not simulated as fixed data values here.

Quick Understanding & Search Notes

VMSGTU.VX does not write an ordinary integer vector; it writes each active element's unsigned greater-than scalar comparison result as one bit of the destination mask. The animation starts from OP-V encoding fields, decodes the vector-scalar operands, then shows per-lane comparison and vd.mask writeback.

The core semantic relation is vd.mask[i] = (unsigned(vs2[i]) > unsigned(x[rs1])); only active body elements generate new destination mask bits.
funct3 selects the OPIVX operand form, funct6 selects the unsigned greater-than scalar relation, and opcode=1010111 is OP-V.
rs1 supplies one integer scalar source, and the same x[rs1] value is compared with each active vs2[i].
vm=0 uses v0.t to select active elements and vm=1 is unmasked; tail and mask-off elements are not forced to concrete values in the animation.

Vector Execution Context

When reading VMSGTU.VX, do not stop at the mnemonic. Official V-extension semantics also depend on the current vl, vtype, and mask state. .vx: one vector source and one integer scalar source participate.

Check vl first

The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.

Then check vtype

The current vtype supplies SEW, LMUL, tail policy, and mask policy; these affect element width, register-group size, and inactive/tail destination elements.

Then check vm/v0

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.

Official source: RISC-V V Standard Extension for Vector Operations

Common Usage Scenarios

Conditional Execution

Understand this scenario with real code like «vmsgtu.vx v1, v2, a1».

Range Check

Understand this scenario with real code like «vmsgtu.vx v1, v2, a1».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is OPIVX.
  • 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

VMSGTU.VX writes vd in mask-register layout, producing one predicate bit per element rather than SEW-wide integer results.
rs1 is the integer scalar register source; the scalar sample value in the animation belongs to execution context, not to assembly syntax.
With vm=0, only body elements selected by v0.t generate new results; mask-off and tail elements should not be taught as definitely writing zero.

FAQ

What format does VMSGTU.VX produce?

The result is written in mask-register layout, one predicate bit per active element, not ordinary SEW-wide vector elements such as 0/1 or 0/-1.

How does the rs1 scalar participate in the compare?

Each active element compares vs2[i] with the same x[rs1] scalar value; rs1 is the assembly operand, while the sample scalar value belongs to execution context.

Does vm or v0.t change the comparison relation?

No. vm only selects which body elements are active; active elements still use this instruction-specific comparison relation to generate mask bits.