riscv_fpu: RMM (roundTiesToAway) for the scalar OP-FP ops#242
Draft
SolAstrius wants to merge 2 commits into
Draft
riscv_fpu: RMM (roundTiesToAway) for the scalar OP-FP ops#242SolAstrius wants to merge 2 commits into
SolAstrius wants to merge 2 commits into
Conversation
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.