FMAXM.S

RISC-V FMAXM.S Instruction Details

Instruction ManualR-type

Return the maximum of two single-precision floating-point operands.

Instruction Syntax

fmaxm.s rd, rs1, rs2
Operand Breakdown
rd: destination floating-point register receiving the formatted result.
rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for rounding mode.
ZfaFFloating-Point Arithmetic

Instruction Behavior

FMAXM.S is the Zfa single-precision IEEE 754-2019 maximum operation: either NaN input produces canonical NaN; otherwise it returns the numerically larger operand. A quiet NaN does not set NV, a signaling NaN sets NV, and -0.0 is less than +0.0.

FMAXM.S Decode And Execute Animation

Shows the Zfa + F-extension single-precision OP-FP flow: decode fields, read FP operands, perform FMAXM semantics, then write rd.

rd
rs1
rs2
fmaxm.s
,
,
Execution Context
FLEN=>=32 / fmt=S (00)
funct3: FMAXM (either NaN is canonical NaN)
fflags: example fflags remains 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00101
FMAXM
00
fmt=S
01100
rs2
01011
rs1
011
funct3=011
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x28C5B553
opcode
1010011 -> OP-FP
funct5/fmt
00101 + S(00) -> FMAXM.S
funct3
011 -> FMAXM (either NaN is canonical NaN)
rd/rs
fa0(f10) / fa1(f11) / fa2(f12)
read
-0.0, 0.0
FP op
FMAXM(-0.0, 0.0) = 0.0
write
fa0(f10) = 0.0; example fflags remains 0
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; single-precision OP-FP instructions use opcode 1010011.

encoding: 0x28C5B553
syntax : fmaxm.s fa0(f10), fa1(f11), fa2(f12)
result : fa0(f10) = 0.0; example fflags remains 0

The default example shows the official signed-zero ordering: -0.0 is less than +0.0. If either input is NaN, Zfa FMINM/FMAXM returns canonical NaN; a signaling NaN sets NV.

Single-precision Calculation
rs1
fa1(f11) = -0.0
rs2
fa2(f12) = 0.0
result
FMAXM(-0.0, 0.0) = 0.0

The default example shows the official signed-zero ordering: -0.0 is less than +0.0. If either input is NaN, Zfa FMINM/FMAXM returns canonical NaN; a signaling NaN sets NV.

This animation shows only Zfa + F-extension ISA-visible OP-FP encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.

Quick Understanding & Search Notes

FMAXM.S is a Zfa OP-FP selection instruction. Its key rule is that either NaN returns canonical NaN, unlike ordinary FMAX.S; it does not use an rm rounding operand.

OP-FP opcode=1010011, funct5=00101, fmt=S(00), and funct3=011 identify FMAXM.S; instruction bit 13 is set relative to FMAX.S.
Either NaN writes canonical NaN; a quiet NaN does not set NV, a signaling NaN sets NV, and -0.0 is less than +0.0.
When FLEN is wider than 32, S-format source operands must be validly NaN-boxed or are treated as canonical S NaNs; an S-format writeback is also NaN-boxed.
The instruction does not use rm; it is a selection operation, not rounded arithmetic.

Common Usage Scenarios

Floating-Point Compare

Understand this scenario with real code like «fmaxm.s f10, f11, f12 ; IEEE 754-2019 max».

Numerical Computing

Understand this scenario with real code like «fmaxm.s f10, f11, f12 ; IEEE 754-2019 max».

Pre-Use Checklist

Syntax Check
  • rd: destination floating-point register receiving the formatted result.
  • rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for rounding mode.
Semantic Check
  • Confirm the floating-point format suffix (.H/.S/.D/.Q) matches the data width.
  • Decide whether software must inspect fflags for NV, DZ, OF, UF, or NX.

Pitfalls / Common Confusions

Unlike ordinary FMIN/FMAX, FMINM/FMAXM returns canonical NaN if either input is NaN.
A quiet NaN also makes the M form write canonical NaN but does not set NV; a signaling NaN writes canonical NaN and sets NV.
-0.0 is considered less than +0.0.

FAQ

What is the main difference from the ordinary form?

The M form returns canonical NaN if either input is NaN; the ordinary form returns the other non-NaN operand when exactly one input is NaN.

Does FMAXM.S round?

No. It selects between two operands and has no rm rounding field.