← Back to Pull requests

Fix : IEEE 754 compliance for SIMD math ops and correct scalar fallback #261

Closed
unknown closed this pull request without merging on May 07, 2026 15:05 UTC
View on GitHub
unknown unknown commented on May 07, 2026 04:34 UTC
Author

Bugs fixed

These functions previously produced incorrect results for non-finite inputs (NaN, ±∞, ±0). All fixes verified against IEEE 754-2008 §9.2 and §6.2.

| Function | Old behavior | Fixed behavior |
|----------|-------------|----------------|
| sin_cos / sin / cos / tan | NaN/±∞ → garbage (polynomial chain on invalid range reduction) | NaN/±∞ → (NaN, NaN) |
| exp | exp(NaN) → 0.0, exp(+∞) → 0.0 | exp(NaN) → NaN, exp(+∞) → +∞ |
| exp | exp(overflow) (e.g. 800.0) → 0.0 | → +∞ |
| exp2 | Same bugs as exp | Same fixes |
| ln | ln(±0) → +∞ (wrong sign) | → -∞ |
| ln | ln(-∞) → -∞ | → NaN (invalid operation) |

Prerequisite fix: is_zero_or_subnormal bitmask

is_zero_or_subnormal used i64x4::round_float(simd_eq(...)) which converts the -1 comparison mask arithmetically to -1.0_f64 (0xBFF0000000000000). This accidentally worked with blend (which only checks the sign bit), but the new IEEE 754 fixes use bitwise &/| patterns that require true bitmask values. Fixed by replacing round_float with cast::<_, f64x4>(mask), a bitwise reinterpret that produces 0xFFFFFFFFFFFFFFFF for true lanes. Applied to all 6 float types.

ln underflow threshold

VM_SMALLEST_NORMAL in f64_.rs was 1.17549435E-38, the f32 smallest normal, instead of 2.2250738585072014E-308 (the f64 value). This caused ln to incorrectly flag all values below 1.17e-38 as underflow.

Known limitation

is_zero_or_subnormal() does not distinguish exponent==0 && mantissa==0 from exponent==0 && mantissa!=0, so subnormals (~1e-308..2.2e-308) are treated as zero in ln. Both old and new code share this behavior, old returned +∞, new returns -∞. True subnormal inputs are essentially never encountered in practice. Documented with a comment.

Tests added

Non-finite edge case tests for sin_cos, exp, exp2, ln in t_f64x4.rs, covering NaN, ±∞, ±0, and finite overflow.

Files changed

src/f64x2_.rs
src/f64x4_.rs
src/f64x8_.rs
src/f32x4_.rs
src/f32x8_.rs
src/f32x16_.rs
tests/all_tests/t_f64x4.rs

All 955 existing tests pass.

Diff: 272 lines (+204 / -68) across 3 files Reviewer: Lokathor Review duration: 631m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 272 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.336
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #261"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.5% (MEDIUM) · Higher = larger blast radius
39.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.1% · Safe to merge
17.1%
Repository