VMADD.VX

RISC-V VMADD.VX Instruction Details

Instruction ManualOPMVX

Multiply old vd by x[rs1], add vs2, and overwrite vd.

Instruction Syntax

vmadd.vx vd, rs1, vs2[, v0.t]
Operand Breakdown
vd supplies the old first multiplicand and receives the SEW-bit result; syntax puts vs1/rs1 before vs2. Active elements write (old vd × second source + vs2) mod 2^SEW.
rs1 selects an integer x-register: take low SEW bits when XLEN>SEW, sign-extend when XLEN<SEW; x0 supplies zero.
Require V 1.0, enabled vector state, valid vtype, and supported widths. Same-EEW source/destination overlap is allowed; masked vd cannot cover v0, and v0 cannot supply both EEW=1 mask and SEW data.
Body is vstart≤i<vl; omitting v0.t means vm=1 and including it means vm=0. Prestart is unchanged; inactive/tail follow vma/vta, with no guarantee of zero agnostic values. VL=0 or vstart≥vl updates no destination.
VVector IntegerMultiply-Add

Extension condition: Requires V 1.0, enabled vector state, valid vtype, and supported element widths.

Instruction Behavior

VMADD.VX is a destructive V 1.0 single-width integer multiply-add instruction. Active elements compute (old vd[i] × scalarSEW(x[rs1]) + vs2[i]) mod 2^SEW and write vd[i]; old vd is the first multiplicand.

VMADD.VX Decode And Execute Animation

Starts from OP-V encoding fields, then shows how VMADD reads old vd as the first multiplicand, adds its low-half product with vs1/rs1 to vs2, and writes the SEW-wide result.

Instruction input
vmadd.vx
Execution Context

The teaching model fixes LMUL=m1 and vstart=0 and shows only body elements in the selected VL. It fixes VLEN=4096, VLMAX=4096/16=256, and assumes support for the selected SEW; equal vector sources require equal elements. In ordinary masked forms, inactive and tail elements follow vtype.vma/vta and the result row does not invent a definite value; VADC/VMADC/VSBC/VMSBC execute every body element, with v0 bits used only as carry/borrow-in.

OP-V encodingvmadd.vx
funct6
101001
vm
0
vs2
01000
rs1
01011
funct3
110
vd
00100
opcode
1010111
lane
0
1
2
3
4
5
6
7
old v4
0xffdf
0x0131
0x0162
0x0193
0xffcb
0x01f5
0x0226
0x0257
v8
0x00fa
0x010b
0x011c
0x012d
0x013e
0x014f
0x0160
0x0171
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
oldvd*+vs2
x11
0x0013
0x0013
0x0013
0x0013
0x0013
0x0013
0x0013
0x0013
v0.t
1
0
1
1
1
0
1
1
v4
...
-
...
...
...
-
...
...
Current step

Show OP-V 32-bit encoding fields

vmadd.vx 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 first-multiplicand-overwrite integer multiply-add, old vd first multiplicand, and vd writeback. It does not model pipelines, caches, or timing.

Quick Understanding & Search Notes

VMADD.VX reads old vd as a multiplicand, adds vs2, and retains the low SEW result bits. Inactive/tail elements follow vma/vta.

32-bit OP-V encoding: opcode=1010111, funct6=101001, funct3=110 (OPMVX). Syntax places vs1/rs1 before vs2.
Active elements compute (old vd[i] × scalarSEW(x[rs1]) + vs2[i]) mod 2^SEW. Old vd is the overwritten first multiplicand, not the VMACC addend.
When XLEN>SEW, use the low SEW bits of x[rs1]; when XLEN<SEW, sign-extend to SEW. rs1=x0 supplies zero.
Body elements satisfy vstart≤i<vl. Omitting v0.t means vm=1; including it means vm=0, enabling only masked-on body elements. Prestart is unchanged; inactive/tail elements follow vma/vta, with agnostic elements retaining old values or becoming all ones.
VL=0 or vstart≥vl updates no destination elements, including tails. Normal completion resets vstart=0 and leaves vl unchanged. Masked vd cannot cover v0, and v0 cannot be read as both an EEW=1 mask and SEW data.

Vector Execution Context

vd supplies the old first multiplicand and receives the SEW-bit result; syntax puts vs1/rs1 before vs2. Active elements write (old vd × second source + vs2) mod 2^SEW.

rs1 selects an integer x-register: take low SEW bits when XLEN>SEW, sign-extend when XLEN<SEW; x0 supplies zero.

Require V 1.0, enabled vector state, valid vtype, and supported widths. Same-EEW source/destination overlap is allowed; masked vd cannot cover v0, and v0 cannot supply both EEW=1 mask and SEW data.

Body is vstart≤i<vl; omitting v0.t means vm=1 and including it means vm=0. Prestart is unchanged; inactive/tail follow vma/vta, with no guarantee of zero agnostic values. VL=0 or vstart≥vl updates no destination.

The RISC-V Instruction Set Manual, Volume I: Unprivileged Architecture — Version 20260120, Chapter 31

Common Usage Scenarios

Elementwise integer multiply-add

Assume RV32/RV64 V, enabled vector state, supported e32,m1, and VLEN≥128; after vsetivli, vl=4, vstart=0, ta/ma, with initialized sources and v0.mask=[1,0,1,1]. old v4=[10,20,30,40], x11=3, v8=[2,4,6,8] → v4=[32,policy,96,128]. policy means mask-agnostic: retain the old value or write all ones; tails are likewise not guaranteed zero.

Pre-Use Checklist

Syntax Check
  • vd supplies the old first multiplicand and receives the SEW-bit result; syntax puts vs1/rs1 before vs2. Active elements write (old vd × second source + vs2) mod 2^SEW.
  • rs1 selects an integer x-register: take low SEW bits when XLEN>SEW, sign-extend when XLEN<SEW; x0 supplies zero.
Semantic Check
  • Require V 1.0, enabled vector state, valid vtype, and supported widths. Same-EEW source/destination overlap is allowed; masked vd cannot cover v0, and v0 cannot supply both EEW=1 mask and SEW data.
  • Body is vstart≤i<vl; omitting v0.t means vm=1 and including it means vm=0. Prestart is unchanged; inactive/tail follow vma/vta, with no guarantee of zero agnostic values. VL=0 or vstart≥vl updates no destination.

Pitfalls / Common Confusions

Same overwrite as vmadd.vv, but multiplier from scalar

FAQ

How does VMADD.VX handle masking and tails?

vm=0 uses v0.t and enables only elements where vstart≤i<vl and the mask bit is 1. vm=1 is unmasked. Prestart is unchanged; inactive/tail elements follow vma/vta. With VL=0 or vstart≥vl, even tails are unchanged.