FMAX.D

RISC-V FMAX.D Instruction Details

Instruction ManualR-type

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

Instruction Syntax

fmax.d 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.
DFloating-Point Arithmetic

Instruction Behavior

FMAX.D selects the numerically larger double-precision operand. Ordinary FMIN/FMAX follows the official minimumNumber/maximumNumber rules: with exactly one NaN input it returns the non-NaN operand, with two NaNs it returns canonical NaN; signaling NaN sets NV, and -0.0 is less than +0.0.

FMAX.D Decode And Execute Animation

Shows the D-extension double-precision OP-FP flow: decode fields, read FP operands, perform FMAX semantics, then write rd.

rd
rs1
rs2
fmax.d
,
,
Execution Context
FLEN=64 / fmt=D (01)
funct3: FMAX selects maximum
fflags: example fflags remains 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00101
FMAX
01
fmt=D
01100
rs2
01011
rs1
001
funct3=001
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x2AC59553
opcode
1010011 -> OP-FP
funct5/fmt
00101 + D(01) -> FMAX.D
funct3
001 -> FMAX selects maximum
rd/rs
fa0(f10) / fa1(f11) / fa2(f12)
read
-0.0, 0.0
FP op
FMAX(-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; double-precision OP-FP instructions use opcode 1010011.

encoding: 0x2AC59553
syntax : fmax.d 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. With NaNs, ordinary FMIN/FMAX returns the non-NaN operand for a single NaN and canonical NaN for two NaNs; signaling NaN sets NV.

Double-precision Calculation
rs1
fa1(f11) = -0.0
rs2
fa2(f12) = 0.0
result
FMAX(-0.0, 0.0) = 0.0

The default example shows the official signed-zero ordering: -0.0 is less than +0.0. With NaNs, ordinary FMIN/FMAX returns the non-NaN operand for a single NaN and canonical NaN for two NaNs; signaling NaN sets NV.

This animation shows only D-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

FMAX.D is an D-extension OP-FP selection instruction, not rounded arithmetic. The key points are how funct5/fmt/funct3 identify FMAX.D, and how NaNs and -0.0/+0.0 affect the selected result.

OP-FP opcode=1010011, funct5=00101, fmt=D, and funct3=001 identify FMAX.D.
Ordinary FMIN/FMAX returns the non-NaN operand for a single NaN; two NaNs return canonical NaN, and signaling NaN sets NV.
-0.0 is less than +0.0; the default animation example is chosen to show this official ordering rule.
There is no rm rounding operand, so the animation shows ISA-visible selection and writeback rather than a rounding path.

Common Usage Scenarios

Floating-Point Compare

Understand this scenario with real code like «fmax.d f0, f1, f2 # f0 = max(f1,f2)».

Numerical Computing

Understand this scenario with real code like «fmax.d f0, f1, f2 # f0 = max(f1,f2)».

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

Ordinary FMIN/FMAX returns the non-NaN operand when exactly one input is NaN; do not confuse it with Zfa FMINM/FMAXM.
A signaling NaN sets NV; when both inputs are NaNs, the result is canonical NaN.
-0.0 is less than +0.0 by the official rule, so signed zero can change the selected result.
This instruction has no rm rounding operand; funct3 selects FMIN or FMAX.

FAQ

Does FMAX.D use the rm rounding mode?

No. The instruction uses funct3 to distinguish FMIN/FMAX and has no rm rounding operand in assembly syntax.

How does FMAX.D differ from FMAXM.D?

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