How is FNMSUB.Q different from FMUL plus add/subtract?
FNMSUB.Q is fused: the product is not first rounded into an intermediate FP result; the whole expression is rounded once at the end according to rm.
quad-precision negated fused multiply-subtract: rd = -(rs1 * rs2) + rs3, with one final rounding according to rm.
FNMSUB.Q uses R4 to compute -(rs1×rs2)+rs3. The product is not separately rounded; rm rounds the final fused expression once to a 128-bit quad-precision result in FP register rd. It supports RV32/RV64 with Q and enabled FP state.
Shows the Q-extension quad-precision R4 negated fused multiply-subtract flow: decode fields, read FP operands, perform FNMSUB semantics, then write rd.
Leave rm empty to use the assembly default dyn encoding and fcsr.frm below.
The word is split as an R4-type instruction; FNMSUB.Q uses its dedicated major opcode 1001011, not the ordinary OP-FP opcode.
The default example -(1.5 * 2.0) + 1.0 = -2.0 is exactly checkable; the fused operation rounds once at the end, so example fflags remains 0.
The default example -(1.5 * 2.0) + 1.0 = -2.0 is exactly checkable; the fused operation rounds once at the end, so example fflags remains 0.
Assumes the extension is available, FS enabled, correctly NaN-boxed inputs, and initial fflags=0. Only nonzero finite exact whitelisted inputs and nonzero whitelisted results are accepted; zero and rounding/exception boundaries are outside this animation. One source register must have one initial value; rd may overlap a source, and f0 accepts writeback. Steps are teaching views.
This animation shows only Q-extension ISA-visible R4 encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.
FNMSUB.Q's key points are R4 encoding and fused semantics: rs3 is a real third source register, and the product plus/minus term forms one exact intermediate expression that is rounded only once.
Assume required extensions and FP state enabled, f1=1.5, f2=2 and f3=1 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the example writes the exact result f0=-(1.5×2)+1=-2; fflags remains 0.
Assume required extensions and FP state enabled, f1=1.5, f2=2 and f3=1 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the example writes the exact result f0=-(1.5×2)+1=-2; fflags remains 0.
FNMSUB.Q is fused: the product is not first rounded into an intermediate FP result; the whole expression is rounded once at the end according to rm.
It needs rd, rs1, rs2, rs3, and rm fields; bits 31..27 hold rs3, not an ordinary R-type funct5 field.
It can accrue NV, OF, UF and NX without clearing existing flags. Infinity times zero sets NV even with a quiet-NaN third source. The exact default example assumes initial fflags=0, so it remains 0.