Clarify that violating nnan and ninf can lead to undefined behavior. This allows more aggressive optimizations based on those assumptions.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
docs/LangRef.rst | ||
---|---|---|
2347 | This is precisely the definition of undef: an arbitrary value that may yield a different value each time it's used. But the intention was to avoid undef and poison. |
This reads clearer to me by avoiding the potential to confuse with UB. Should the same blurb apply to nsz with -0.0?
I don't think this is right. Saying the result is undefined seems like what we intend. We might choose, as an implementation technique, to limit how we take advantage of that undefinedness in certain cases, but the violating the constraint still produces logical inconsistencies that can transfer to other parts of the code, and in general, turn into any other kind of undefined behavior (depending on the structure of the code).
It has to be one of undefined behavior, poison, undef, or an unspecified value as described here; there is no other way for something to be "undefined" in LLVM IR, unless you're proposing to introduce a new form of undefined-ness specifically for nnan/ninf.
I think we should have these produce poison -- if we have them produce undef we'll have the same kinds of problems as we have with regular undef.
nnan and ninf affect fcmp
Only if the fcmp is marked with nnan or ninf right?
Only if the fcmp is marked with nnan or ninf right?
Yes, but it's inconvenient in C because fast-math flags work on a per-file basis.
If the consensus is that we need to produce poison for nnan/ninf instead of an unspecified value, I can change that. I guess it allows more aggressive fcmp transforms in some cases?
This is precisely the definition of undef: an arbitrary value that may yield a different value each time it's used. But the intention was to avoid undef and poison.
I'm not familiar enough with floats to make any concrete suggestion; I'm just type checking.