FMAX.H

RISC-V FMAX.H Instruction Details

Instruction ManualR-type

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

Instruction Syntax

fmax.h 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.
ZfhFloating-Point Arithmetic

Instruction Behavior

FMAX.H returns the numerically larger of two half-precision floating-point operands. If only one operand is NaN, it returns the non-NaN operand; if both are NaN, it returns canonical NaN. A signaling NaN sets NV, and -0.0 is less than +0.0.

Quick Understanding & Search Notes

FMAX.H's key search point is NaN handling. The ordinary form selects the non-NaN operand for a single NaN and returns canonical NaN only when both inputs are NaN.

-0.0 and +0.0 are ordered: -0.0 is less than +0.0.
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 «fmax.h f10, f11, f12 ; f10 = max(f11, f12)».

Numerical Computing

Understand this scenario with real code like «fmax.h f10, f11, f12 ; f10 = max(f11, f12)».

Pre-Use Checklist

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

Ordinary FMIN/FMAX returns the non-NaN operand when exactly one input is NaN.
A signaling NaN sets NV; quiet-NaN handling differs between ordinary and M forms.
-0.0 is considered less than +0.0.

FAQ

What is the main difference from the M form?

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

Does FMAX.H round?

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