FSGNJ.S

RISC-V FSGNJ.S Instruction Details

Instruction ManualR-type

The result keeps rs1 magnitude bits and takes its sign from the rs2 sign.

Instruction Syntax

fsgnj.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.
FFloating-Point Arithmetic

Instruction Behavior

FSGNJ.S only recombines the sign bit of a single-precision floating-point encoding: exponent and significand fields come from rs1, while the sign is produced from the rs2 sign. It performs no floating-point arithmetic, does not round, sets no floating-point exception flags, and does not canonicalize NaNs.

Quick Understanding & Search Notes

FSGNJ.S answers searches such as why floating negate/absolute/copy does not raise exceptions. It only manipulates sign-bit information and leaves rs1 exponent and significand bits unchanged.

With rs2=rs1, FSGNJ/FSGNJN/FSGNJX correspond to common FMV/FNEG/FABS pseudo-instruction semantics.
These instructions have no rm field and do not set fflags.

Common Usage Scenarios

Sign Operations

Understand this scenario with real code like «fsgnj.s f0, f1, f2 # f0 = f1 with sign of f2».

Floating-Point Bit Manipulation

Understand this scenario with real code like «fsgnj.s f0, f1, f2 # f0 = f1 with sign of f2».

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

This is a bit-level sign operation, not arithmetic or numeric conversion.
It sets no exception flags and does not canonicalize NaNs.
rs2=rs1 is commonly used for the FMV pseudo-instruction.

FAQ

Does FSGNJ.S change the NaN payload?

It does not canonicalize NaNs; except for the sign bit rule, the remaining rs1 bits are preserved.

Is FSGNJ.S a numeric conversion?

No. It is a bit-level sign operation inside floating-point registers.