Fix NaN-boxing and sign extension of narrow scalar FP moves - #123
Open
Smephite wants to merge 3 commits into
Open
Fix NaN-boxing and sign extension of narrow scalar FP moves#123Smephite wants to merge 3 commits into
Smephite wants to merge 3 commits into
Conversation
Smephite
force-pushed
the
kberszin/fix-fp-fmv-nanbox
branch
from
July 23, 2026 13:40
d1829d2 to
a10f76d
Compare
Smephite
force-pushed
the
kberszin/fix-fp-fmv-nanbox
branch
2 times, most recently
from
July 23, 2026 14:15
2efc7a1 to
fd8fe4d
Compare
Smephite
force-pushed
the
kberszin/fix-fp-fmv-nanbox
branch
from
July 23, 2026 15:30
fd8fe4d to
1ba405e
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
The FPU sequencer mishandles both directions of narrow scalar moves between the GPR and FP register files:
fmv.s.x,fmv.h.x,fmv.b.x): the value written to the FPR was the raw sign-extended operand from Snitch instead of a NaN-boxed one. Narrow values are required to be extended with '1.fmv.x.h,fmv.x.b): the move result forwarded the raw FPR word, so the upper GPR bits came from the NaN-box (all 1s) instead of sign-extending the narrow value. Positive half/byte float read back as0xFFFFxxxx/0xFFFFFFxx.This PR fixes this issue by handling the different widths and extending / truncating accordingly.
Testing
New regression test
riscvTests/fmv_narrowcovers both directions:fmv.x.scontrol)fmv.x.sfor the 16/8-bit boxes,fsdfor the upper 32 box bits on FLEN=64)