Skip to content

refactor: extract float NaN/subnormal helpers (H-1.4, H-1.5)#78

Closed
avrabe wants to merge 1 commit intomainfrom
feat/wave3-float-helpers
Closed

refactor: extract float NaN/subnormal helpers (H-1.4, H-1.5)#78
avrabe wants to merge 1 commit intomainfrom
feat/wave3-float-helpers

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 13, 2026

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 constants
  • is_f32_subnormal() / is_f64_subnormal() — subnormal detection
  • canonicalize_f32() / canonicalize_f64() — returns canonical NaN bits if NaN, else result bits

Replaces 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
  • All pre-commit hooks pass

🤖 Generated with Claude Code

…, 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>
@avrabe
Copy link
Copy Markdown
Contributor Author

avrabe commented Apr 13, 2026

Superseded by PR #79 which includes these float helper changes plus SC→REQ traceability links.

@avrabe avrabe closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant