riscv_fpu: honor static RMM rounding-mode field#235
Closed
SolAstrius wants to merge 2 commits into
Closed
Conversation
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Signed-off-by: Sol Astrius Phoenix <sol@astrius.ink>
Contributor
Author
|
Superseded by #233, which now carries static rounding-mode support as its own commit ("honor the static rounding-mode field") and generalizes it to all static modes (rtz/rdn/rup/rmm), not just RMM. |
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
Extends #233 so that RMM (IEEE 754
roundTiesToAway) is honored when it is selected by the staticrmfield of an instruction (e.g.fadd.s …,rmm), not only by the dynamicfrmCSR.Background
#233 fixes RMM but only triggers on
frm == RMM(dynamic rounding). The RISC-V spec also allows RMM to be encoded statically in the instruction'srmfield; RVVM previously ignored a staticrmfor arithmetic ops entirely (onlyfrmdrove the host mode). Sofadd.s rd,rs1,rs2,rmmunder the defaultfrmwas computed as round-to-nearest-even.Change
rm == 0b100(static) orrm == DYN && frm == RMM(dynamic).funct3 == 0b100only ever appears on rounding-capable ops, so the static check can't misfire onfsgnj/fcmp/fclass/etc.,rmmunder a directedfrmis the only case where the host (which tracksfrm) isn't already nearest, so the fixup helpers wrap the op in a self-eliminating guard: it reads the host mode and only switches to RNE (restoring after) when it isn't already RNE. For the common cases (dynamic RMM, or static,rmmunder the defaultfrm) it's a no-op, so the hot path is untouched.Validation
frm=RMMand static,rmm— plus a dedicated check that a directedfrm(e.g. RTZ) survives a static-,rmmop (host mode restored). All pass (3006 vector-checks + restore), MPFR-oracle expected values, f32+f64, incl. subnormals/boundary.Out of scope (same as #233)
rmfor the other directed modes (rtz/rdn/rup) on arithmetic is still not honored — only RMM is addressed here.fcvt-to-integer under RMM still rounds ties-to-even.