[llvm-dev] Question on fast-math optimizations

Stephen Canon via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 30 06:34:44 PST 2018


> On Nov 30, 2018, at 9:24 AM, Nicolai Hähnle via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Stephen was a bit hesitant about what to call the x * (y + 1) --> x * y + x FMA-introducing transform on the grounds that it superficially only seems to improve the precision at which the expression is evaluated.

It’s a little bit more subtle than that; because FMA is computed without internal rounding, under an as-if model, you can’t differentiate between fma(x, y, x) and a hypothetical correctly-rounded x*(y + 1), so it doesn’t even make sense to talk about “distributivity” in this context ...

> My point was that this very same transform can introduce very significant, qualitative differences in the result when inf is involved.

… except with regard to inf/nan edge cases, as you correctly pointed out. =)

– Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181130/576d275a/attachment.html>


More information about the llvm-dev mailing list