VFMAX.VF

RISC-V VFMAX.VF Instruction Details

Instruction ManualV-type

VFMAX.VF is an RVV single-width floating-point maximum selection instruction with syntax vfmax.vf vd, vs2, rs1, vm; each active element compares vs2[i] with f[rs1] and writes the maximum to vd[i].

Instruction Syntax

vfmax.vf vd, vs2, rs1, vm
Operand Breakdown
vd and vs2 are SEW-wide vector groups; same-EEW destination/source overlap is legal and equal sources read equal initial values. There is no immediate operand.
rs1 selects FP f0–f31 or an ABI name; when FLEN>SEW an invalid NaN box is read as canonical NaN.
Assembly vm is optional v0.t; omission means vm=1. Only active elements with vstart≤i<vl and (vm=1 or v0[i]=1) perform minimumNumber/maximumNumber.
Require V, supported vtype and FP widths, and enabled VS/FS; V supports FP32/FP64 and depends on F/D. With H and virtualization V=1, vsstatus.VS/FS must also be enabled. Invalid frm use is reserved even if no rounding occurs or vl=0.
Prestart is unchanged; vl=0 or vstart≥vl leaves every destination element, including tails, unchanged. Otherwise inactive/tail elements follow vma/vta, with no guaranteed zeroing or preservation.
With vm=0, vd cannot overlap v0; v0 cannot supply both an EEW=1 selection/mask source and SEW data. Successful execution resets vstart to zero.
VVector OperationsFloating-Point

Instruction Behavior

VFMAX.VF performs lane-wise floating-point maximum selection on active elements within vl. The second source is scalar FP register f[rs1]; with vm=0, v0.t controls which elements execute, and vm=1 is unmasked. NaN handling, signaling-NaN invalid flag, signed zero, and result selection follow the official RISC-V FMIN/FMAX rules; this is not integer min/max, saturation, or fused multiply-add.

VFMAX.VF Decode And Execute Animation

Decode the OP-V encoding and execute lane-wise FP maximum selection with the second source from scalar f[rs1].

Instruction input
vfmax.vf
Execution context
LMULm1fixed register-group multiplier
VLEN4096fixed vector-register length (bits)
VLMAX128maximum element count at m1
vstart0prestart elements are outside this animation
frmRNEnot rounded by frm; the architectural instruction still requires valid frm
FP stateFS enabledFS=Off raises illegal instruction; this animation fixes the architectural state to FS enabled
vta/vmata, matail/inactive policy
opcode1010111OP-V major opcode
Encoding fields
0x18855257
31..26
25
24..20
19..15
14..12
11..7
6..0
000110
funct6
0
vm
01000
vs2
01010
rs1
101
funct3
00100
vd
1010111
OP-V
Execution data path

lane 0: max(1, 1.5) -> 0x3fc00000 (1.5)

This lane follows the current-step highlight; the remaining lane results appear below.

Step 1 / 15
Read OP-V encoding fields

V-extension FP instructions use the OP-V major opcode, with funct6, source registers, vm, funct3, vd, and opcode fields.

Lane results
This execution does not raise NVLong vectors scroll inside this module without page overflow.
i=0active
max(1, 1.5)
0x3fc00000 (1.5)
i=1active
max(1.5, 1.5)
0x3fc00000 (1.5)
i=2skip
v0.t=0, not executed
--
i=3active
max(2.5, 1.5)
0x40200000 (2.5)
i=4active
max(-3, 1.5)
0x3fc00000 (1.5)
i=5active
max(3.5, 1.5)
0x40600000 (3.5)
i=6skip
v0.t=0, not executed
--
i=7active
max(4.5, 1.5)
0x40900000 (4.5)
Inputs are first represented as SEW=32 / binary32, then FMIN/FMAX selects: one NaN returns the other input, two NaNs return canonical NaN, and any active sNaN raises NV. -0 is less than +0; equal-sign zeros retain their sign. Selection does not round by frm, but the architectural instruction still requires valid frm. The NV indicator shows what this execution raises, not a clearing or full snapshot of existing fflags.

This teaching context fixes VS/FS enabled, valid vtype, frm=RNE, and FLEN=64; a SEW=32 scalar input represents the low 32 bits of a valid NaN box. Equal sources require equal bits. Same-width destination/source overlap is legal; ta/ma gives no definite inactive or tail value. At VL=0 no destination elements, including tails, are updated.

Quick Understanding & Search Notes

VFMAX.VF is best understood through OP-V encoding, scalar FP register f[rs1], v0.t masking, and per-active-element vd[i] = max(vs2[i], f[rs1]).

In the OP-V encoding, funct6=000110 and funct3=101 select the vector-scalar FP maximum form for vfmax.vf.
The semantic operation is vd[i] = max(vs2[i], f[rs1]) for active elements within vl.
vm=0 uses v0.t as the execution mask; vm=1 is unmasked.
One NaN input returns the non-NaN input; two NaNs return canonical NaN. Any signaling NaN raises fflags.NV even when a number is returned; quiet NaN alone does not. For min/max, -0.0 is less than +0.0; equal-sign zeros retain their sign.
For ordinary masked vector instructions, the destination vector register group must not overlap the v0 mask source; the animation rejects vd=v0 when vm=0.
This page covers V 1.0: V depends on F/D and supports FP SEW=32/64; VS/FS must be enabled and vtype valid. An invalid frm is reserved even though this operation does not round by frm. The scalar comes from an f register; when FLEN>SEW, an invalid NaN box is read as canonical NaN.

Vector Execution Context

vd and vs2 are SEW-wide vector groups; same-EEW destination/source overlap is legal and equal sources read equal initial values. There is no immediate operand.

rs1 selects FP f0–f31 or an ABI name; when FLEN>SEW an invalid NaN box is read as canonical NaN.

Assembly vm is optional v0.t; omission means vm=1. Only active elements with vstart≤i<vl and (vm=1 or v0[i]=1) perform minimumNumber/maximumNumber.

Require V, supported vtype and FP widths, and enabled VS/FS; V supports FP32/FP64 and depends on F/D. With H and virtualization V=1, vsstatus.VS/FS must also be enabled. Invalid frm use is reserved even if no rounding occurs or vl=0.

Prestart is unchanged; vl=0 or vstart≥vl leaves every destination element, including tails, unchanged. Otherwise inactive/tail elements follow vma/vta, with no guaranteed zeroing or preservation.

With vm=0, vd cannot overlap v0; v0 cannot supply both an EEW=1 selection/mask source and SEW data. Successful execution resets vstart to zero.

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

Common Usage Scenarios

Lane-wise FP maximum

Assume V/VS/FS enabled, valid frm, supported e32,m1, VLMAX≥4, x10=4, vstart=0, and v2=[1,-2,3,+0]; scalars are validly NaN-boxed. f0=1.5 → v1=[1.5,1.5,3,1.5]. Min/max examples omit v0.t, so all four body elements execute; merge uses v0 only for selection. Tails follow ta without assumed zeroing.

Lower-bound clipping

Assume V/VS/FS enabled, valid frm, supported e32,m1, VLMAX≥4, x10=4, vstart=0, and v2=[1,-2,3,+0]; scalars are validly NaN-boxed. f0=1.5 → v1=[1.5,1.5,3,1.5]. Min/max examples omit v0.t, so all four body elements execute; merge uses v0 only for selection. Tails follow ta without assumed zeroing.

Pre-Use Checklist

Syntax Check
  • vd and vs2 are SEW-wide vector groups; same-EEW destination/source overlap is legal and equal sources read equal initial values. There is no immediate operand.
  • rs1 selects FP f0–f31 or an ABI name; when FLEN>SEW an invalid NaN box is read as canonical NaN.
Semantic Check
  • Assembly vm is optional v0.t; omission means vm=1. Only active elements with vstart≤i<vl and (vm=1 or v0[i]=1) perform minimumNumber/maximumNumber.
  • Require V, supported vtype and FP widths, and enabled VS/FS; V supports FP32/FP64 and depends on F/D. With H and virtualization V=1, vsstatus.VS/FS must also be enabled. Invalid frm use is reserved even if no rounding occurs or vl=0.
  • Prestart is unchanged; vl=0 or vstart≥vl leaves every destination element, including tails, unchanged. Otherwise inactive/tail elements follow vma/vta, with no guaranteed zeroing or preservation.
  • With vm=0, vd cannot overlap v0; v0 cannot supply both an EEW=1 selection/mask source and SEW data. Successful execution resets vstart to zero.

Pitfalls / Common Confusions

Operand order is vs2[i] and f[rs1] for maximum selection; do not treat it as a cross-lane reduction.
NaNs and signed zeros are not just ordinary numeric comparison; follow the official FMIN/FMAX rules.
This is not integer min/max, saturating clipping, or FMA; the result is a floating-point value selection.
With vm=0, only v0.t=1 active elements execute; with vm=1, all body elements execute. Masked-off elements follow vma and are not guaranteed to be zero or preserved.
When vm=0 uses v0.t as the execution mask, the ordinary destination vector register group must not overlap the v0 mask register.

FAQ

What does the vm operand control for VFMAX.VF?

With vm=0, only active elements selected by v0.t execute; vm=1 is unmasked. The page formula is vd[i] = max(vs2[i], f[rs1]).

Is VFMAX.VF a reduction min/max instruction?

No. It produces one destination vector element per lane; cross-element min/max reductions use the corresponding vector reduction instructions.

How does VFMAX.VF handle NaNs and signed zero?

One NaN input returns the non-NaN input; two NaNs return canonical NaN. Any signaling NaN raises fflags.NV even when a number is returned; quiet NaN alone does not. For min/max, -0.0 is less than +0.0; equal-sign zeros retain their sign.