[clang] [llvm] Clang: Add nsz to llvm.minnum and llvm.maxnum emitted from fmin and fmax (PR #113133)

YunQiang Su via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 26 01:55:03 PDT 2025


wzssyqa wrote:

> > > I'm not sure this is correct. At least the way alive models the flag, I believe this would also allow returning -0.0 even if both operands are 0.0, which is not a legal outcome.
> > 
> > 
> > That sounds like a bad modeling. It shouldn't permit synthesizing a -0 out of nowhere
> 
> Hm, how would you suggest to model it? Considering an example like https://discourse.llvm.org/t/rfc-clarify-the-behavior-of-fp-operations-on-bit-strings-with-nsz-flag/85981/4?u=nikic, looking at it from the perspective of the select only, requires it to convert a 0.0 into -0.0 "out of nowhere".
> 
> I guess we could specify the semantics of nsz per-operation and use something different for minnum...

In fact we already do so.
```
If the intrinsic is marked with the nsz attribute, then the effect is as in the definition in C and IEEE-754-2008: the result of minnum(-0.0, +0.0) may be either -0.0 or +0.0.
```

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


More information about the cfe-commits mailing list