Fix : IEEE 754 compliance for SIMD math ops and correct scalar fallback #261
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Lokathor
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 asexp| Same fixes ||
ln|ln(±0)→+∞(wrong sign) | →-∞||
ln|ln(-∞)→-∞| → NaN (invalid operation) |Prerequisite fix:
is_zero_or_subnormalbitmaskis_zero_or_subnormalusedi64x4::round_float(simd_eq(...))which converts the-1comparison mask arithmetically to-1.0_f64(0xBFF0000000000000). This accidentally worked withblend(which only checks the sign bit), but the new IEEE 754 fixes use bitwise&/|patterns that require true bitmask values. Fixed by replacinground_floatwithcast::<_, f64x4>(mask), a bitwise reinterpret that produces0xFFFFFFFFFFFFFFFFfor true lanes. Applied to all 6 float types.lnunderflow thresholdVM_SMALLEST_NORMALinf64_.rswas1.17549435E-38, the f32 smallest normal, instead of2.2250738585072014E-308(the f64 value). This causedlnto incorrectly flag all values below 1.17e-38 as underflow.Known limitation
is_zero_or_subnormal()does not distinguishexponent==0 && mantissa==0fromexponent==0 && mantissa!=0, so subnormals (~1e-308..2.2e-308) are treated as zero inln. 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,lnint_f64x4.rs, covering NaN, ±∞, ±0, and finite overflow.Files changed
All 955 existing tests pass.