VASUB.VX

RISC-V VASUB.VX Instruction Details

Instruction ManualR-type

Vector signed averaging subtract: vd[i] = roundoff_signed(vs2[i] - x[rs1], 1).

Instruction Syntax

vasub.vx vd, vs2, rs1, 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 OperationsFixed-Point Arithmetic

Instruction Behavior

VASUB.VX performs RVV signed fixed-point averaging subtract. The difference is right-shifted by one bit and rounded according to vxrm; the SEW-width result is written back, and this is not a saturating subtract.

Quick Understanding & Search Notes

VASUB.VX is fixed-point averaging subtract; the key distinctions are signed interpretation and vxrm rounding.

The rounding mode comes from vxrm (rnu/rne/rdn/rod), not floating-point frm.
The result is not saturated; use saturating fixed-point instructions when saturation is required.
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

Signal Processing

Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vasub.vx v1, v2, a1».

Image Processing

Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vasub.vx v1, v2, a1».

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

Rounding follows vxrm (rnu/rne/rdn/rod); it is not a fixed '+1 then shift' operation.
vasub/vasubu ignore overflow and wrap; vaadd/vaaddu have no result overflow.

FAQ

What is the difference between VASUB and VASUBU?

VASUB interprets elements as signed, while VASUBU interprets them as unsigned; both use vxrm for averaging-subtract rounding.