llvm-project
a8ba9c4f - [flang] Fix spurious NaN result from infinite Kahan summation (#175373)

Commit
41 days ago
[flang] Fix spurious NaN result from infinite Kahan summation (#175373) There are six instances of Kahan's extended precision summation algorithm in flang/flang-rt, and they share a bug: the calculation of the correction value produces a Nan due to the subtraction Inf-Inf after the accumulation saturates to Inf. This leads to the surprising Nan result from SUM([Inf, 0.]). This bug doesn't affect run-time calculation of SUM when optimization is enabled -- lowering emits an open-coded SUM that lacks Kahan summation -- but it does affect compilation-time folding and -O0 runtime results. Fix the one instance of Kahan summation in the runtime, and consolidate the other five instances in Evaluate into one new member function, also corrected. Fixes https://github.com/llvm/llvm-project/issues/89528.
Author
Parents
Loading