refactor: extract float NaN/subnormal helpers (H-1.4, H-1.5)#78
Closed
refactor: extract float NaN/subnormal helpers (H-1.4, H-1.5)#78
Conversation
…, H-1.5) Extract inline NaN canonicalization and subnormal checks into reusable helper functions: F32/F64_CANONICAL_NAN constants, is_f32/f64_subnormal(), canonicalize_f32/f64(). Pure refactor, no behavioral change. Makes the float constant folding code auditable against hazards H-1.4 (non-canonical NaN) and H-1.5 (subnormal flushing). Trace: H-1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Superseded by PR #79 which includes these float helper changes plus SC→REQ traceability links. |
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
Extract inline float NaN canonicalization and subnormal checks into reusable helper functions. Pure refactor — no behavioral change.
New helpers
F32_CANONICAL_NAN/F64_CANONICAL_NAN— WebAssembly spec canonical NaN constantsis_f32_subnormal()/is_f64_subnormal()— subnormal detectioncanonicalize_f32()/canonicalize_f64()— returns canonical NaN bits if NaN, else result bitsReplaces inline patterns across 8 arithmetic fold sites (f32/f64 add/sub/mul/div).
Why
Makes float constant folding code auditable against STPA hazards H-1.4 (non-canonical NaN production) and H-1.5 (subnormal flushing on ARM). Reviewer can verify correctness by inspecting 6 helper functions instead of 8 scattered match arms.
Test plan
cargo test --release— all tests pass unchanged🤖 Generated with Claude Code