fix(vfp): correct f32/f64 rounding for ceil/floor/nearest#51
Merged
Conversation
PR #47 implemented f32 rounding pseudo-ops but had two bugs: 1. The rounding mode values for ceil (0b01) and floor (0b10) were swapped 2. All rounding modes used VCVTR.S32.F32 which always truncates toward zero, ignoring the mode parameter entirely Fix by properly manipulating the FPSCR rounding mode bits [23:22] for ceil/floor/nearest, using the non-R variant of VCVT.S32.F32 (bit[7]=0) which honours the FPSCR rounding mode, then restoring FPSCR afterward. Trunc continues to use VCVTR (the R variant). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Same bug as f32: the f64 rounding encoder ignored the mode parameter and always truncated toward zero. Also ceil/floor mode values were swapped (ceil had 0b10 instead of 0b01, floor had 0b01 instead of 0b10). Applies the same FPSCR rounding-mode manipulation fix to both ARM32 and Thumb-2 f64 encoders. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ceil/floor/nearest all produced truncation — ignored rounding mode param and had ceil/floor FPSCR values swapped. Fixed both f32 and f64 encoders to manipulate FPSCR rounding bits correctly.
Test plan
🤖 Generated with Claude Code