From e18c2a3500015c087e6177cefc1f30dfd3f70aaf Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 13 Oct 2026 16:17:53 +0200 Subject: [PATCH] Don't allow reassociation in two_sum `@fastmath` on the sum in two_sum lets the compiler reassociate it. LLVM 23's SLP vectorizer uses that to compute the final hi of a compensated reduction with a tree-shaped vector reduction, while the error terms still come from the sequential partial sums, so the compensation is lost. An error-free transformation needs hi to be exactly fl(a + b). Assisted-by: Claude Code (Opus 5.5) --- src/errorfree.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/errorfree.jl b/src/errorfree.jl index a05e2a7..b45777b 100644 --- a/src/errorfree.jl +++ b/src/errorfree.jl @@ -8,7 +8,7 @@ This algorithm does not use any branch. See also `fast_two_sum` for an alternative algorithm which branches but does fewer arithmetic operations. """ @inline function two_sum(a::T, b::T) where {T} - @fastmath hi = a + b + hi = a + b v = hi - a lo = (a - (hi - v)) + (b - v) return hi, lo