riscv_fpu: RMM (roundTiesToAway) for the scalar OP-FP ops#242
Draft
SolAstrius wants to merge 3 commits into
Draft
riscv_fpu: RMM (roundTiesToAway) for the scalar OP-FP ops#242SolAstrius wants to merge 3 commits into
SolAstrius wants to merge 3 commits into
Conversation
Contributor
Author
|
@purplesyringa addressed the #239 comments that apply here: the RMM fixups now live in fpu_lib next to the error-free transforms, with a header note that RMM is riscv-specific (as agreed), and the div_apply naming inconsistency is gone. Dynamic-frm RMM harness passes 21826/21826; static rm handling stays a separate patch. Keeping it draft so it doesn't get merged by accident again — review when you have time. |
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink> (cherry picked from commit 685255b)
…low boundary Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink> (cherry picked from commit 81d257c)
Review feedback on LekKit#239: the math-heavy tie fixups belong in fpu_lib next to the error-free transform machinery they build on, with an explicit header note that RMM is a RISC-V-specific rounding mode (a native RISC-V host could bypass the fixups entirely). Also aligns the fdiv fixup naming (riscv_rmm_div_apply -> fpu_rmm_div) with the add/mul helpers. No functional change; the RMM harness still passes all 21826 dynamic-frm vectors. Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
SolAstrius
force-pushed
the
fix/rmm-roundtiestoaway
branch
from
July 17, 2026 22:48
ed93382 to
2295b9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix RMM (round to nearest, ties to max magnitude — IEEE 754
roundTiesToAway) for the scalar arithmetic ops, addressing #204. Standalone onstaging; no dependency on the other in-flight FPU work.The host FPU has no RMM mode, so under
frm == RMMthe host is left in round-to-nearest-even. RNE and roundTiesToAway differ only on an exact halfway tie. The previousriscv_prepare_rmmrounded toward ±inf unconditionally — correct on ties but wrong for every inexact non-tie. This replaces it with: compute in RNE, recover the exact rounding error via the library's error-free transforms (TwoSum / TwoProduct), and step one ULP outward only on a true half-ULP tie.What's covered
.sand.d.Scope / draft notes
Deliberately minimal and independent, so it can be reviewed on its own (per review feedback that RMM is too complex to evaluate bundled with the rest):
frm == RMM,rm == DYN). The static,rmminstruction suffix needs host-rounding-mode forcing and lands with the rounding-mode rework.Draft until the companion FPU PRs settle (it lightly overlaps the fadd/fsub/fmul/fdiv read sites with the canonicalization/mal-box PR, so ordering may want a trivial rebase).
Touches
src/cpu/riscv_fpu.conly.