FSQRT.H

RISC-V FSQRT.H Instruction Details

Instruction ManualR-type

Half-precision floating-point square root: rd = sqrt(rs1).

Instruction Syntax

fsqrt.h rd, rs1, rm
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

FSQRT.H computes the half-precision floating-point square root, rounds according to rm or the dynamic rounding mode, and writes rd. A negative nonzero finite operand or -infinity produces canonical NaN and sets NV; sqrt(-0) remains -0.

Quick Understanding & Search Notes

FSQRT.H is a Zfh-related half-precision floating-point square root instruction. It produces a floating-register result, uses rm when rounding is required, and records floating-point exception flags such as NV, DZ, OF, UF, and NX in fflags.

The .H suffix selects the operand and result floating-point format; narrower formats in wider FLEN registers follow NaN-boxing rules.
rm is a machine-instruction field; when assembly omits it, the assembler usually selects dynamic rounding or its default spelling.

Common Usage Scenarios

Floating Point Basic

Understand this scenario with real code like «fsqrt.h f10, f11, rne ; f10 = sqrt(f11)».

Numerical Computing

Understand this scenario with real code like «fsqrt.h f10, f11, rne ; f10 = sqrt(f11)».

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

Rounding comes from the rm field; rm=111 uses the dynamic frm rounding mode.
Floating-point exceptions are recorded in fflags, not as integer branch conditions or integer traps.
The square-root negative-input edge case distinguishes -0 from other negative values.

FAQ

Does FSQRT.H raise integer exceptions?

No. RISC-V floating-point exceptions are accrued in fflags; software reads floating-point status state to observe them.

What does rm mean for FSQRT.H?

rm selects the rounding mode; the dynamic rounding mode comes from frm. For exact results it does not change the value, but the field is still part of the instruction encoding.