FNMADD.S

RISC-V FNMADD.S Instruction Details

Instruction ManualR4-type

Single-precision negated fused multiply-add: rd = -(rs1 * rs2) - rs3, rounded once.

Instruction Syntax

fnmadd.s rd, rs1, rs2, rs3, rm
Operand Breakdown
rd: destination floating-point register.
rs1, rs2, rs3: three source floating-point registers; R4 is not an ordinary three-register R-type form.
rm: rounding-mode field for the final fused multiply-add/subtract result.
FFloating-Point Arithmetic

Instruction Behavior

FNMADD.S uses the R4 four-register format for single-precision negated fused multiply-add. The multiply and add/subtract are fused, so the exact intermediate result is rounded only once at the end according to rm before being written to rd.

Quick Understanding & Search Notes

FNMADD.S's key property is fusion: the product and add/subtract term are not written as an intermediate result and are rounded once at the final step.

The R4 format includes rs3; do not read it as an ordinary three-register R-type instruction.
The sign rules follow the official definitions: FMADD adds rs3, FMSUB subtracts rs3, and FNMADD/FNMSUB use the negated fused-result variants.

Common Usage Scenarios

Fused Floating Point

Understand this scenario with real code like «fnmadd.s f0, f1, f2, f3 # f0 = -(f1*f2)-f3».

Numerical Computing

Understand this scenario with real code like «fnmadd.s f0, f1, f2, f3 # f0 = -(f1*f2)-f3».

Pre-Use Checklist

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

FMA rounds once and is not equivalent to a separate FMUL followed by FADD/FSUB with two roundings.
The negated FNMSUB/FNMADD sign rules are easy to confuse with ordinary FMSUB/FMADD.
rm controls the single final rounding; exception flags accrue for the fused operation.

FAQ

How is FNMADD.S different from FMUL plus add/subtract?

The fused instruction performs one final rounding; two separate instructions round the product first and then round the add/subtract result.

Why is FNMADD.S R4-type?

It needs rd, rs1, rs2, and rs3 register fields for the two multiply sources and the add/subtract term.