[llvm] LangRef: state explicitly that floats generally behave according to IEEE-754 (PR #102140)

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 00:07:54 PDT 2024


RalfJung wrote:

> I'm not entirely certain this is the best way to do it. IEEE 754 just isn't quite precise enough to say that "it's just IEEE 754 behavior!" answers the questions that people are trying to ask.

It answers some questions. Like, currently the LangRef does not say what the result of `fadd` on  half, float, double, and fp128 even is. It says that the arguments and return values are interpreted using the IEEE-754 binary format, but doesn't say how the return value is computed -- so every frontend that relies on this being "the infinite-precision result, sounded to the next representable number, with round-ties-to-even" is technically incorrect. I think it should be possible to provide at least this basic promise.

I will restrict the new part to only apply to those types, not all float types.

> What I think should be explicitly mentioned are these:

To me these are both direct consequences of just saying unambiguously what the result is -- if the result can only be this, any optimization that changes the result is obviously wrong. But I can add clarifications to make sure this point is clear.

https://github.com/llvm/llvm-project/pull/102140


More information about the llvm-commits mailing list