Skip to content

riscv_fpu: canonicalize NaN results and mal-boxed narrow operands#240

Open
SolAstrius wants to merge 11 commits into
LekKit:stagingfrom
pufit:fix/fpu-nan-canon
Open

riscv_fpu: canonicalize NaN results and mal-boxed narrow operands#240
SolAstrius wants to merge 11 commits into
LekKit:stagingfrom
pufit:fix/fpu-nan-canon

Conversation

@SolAstrius

Copy link
Copy Markdown
Contributor

Summary

Canonicalize NaN on the scalar F/D path, on both the result and the operand side.

What's fixed

  • Arithmetic and FMA results — fadd/fsub/fmul/fdiv/fsqrt and the full FMA family (fmadd/fmsub/fnmsub/fnmadd) route their result through the canonicalizing write path, so a NaN result is delivered as the canonical quiet NaN.
  • Mal-boxed narrow operands — a narrow (f32) operand that is not correctly NaN-boxed in its 64-bit register reads as the canonical NaN per the RISC-V NaN-boxing rule, across arithmetic, conversions, sign-injection, min/max, compares, classification, and the FMA family.

Validation

Together with the rounding/exception work in #239, riscv-arch-test (ACT4, Spike reference) F/D/I/M reaches 260/260.

Notes

Stacked on #239 — its nine commits appear here until it merges, after which only the two canonical-NaN commits remain. No functional change outside src/cpu/riscv_fpu.{c,h}.

Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
…low boundary

Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant