[llvm] Intrinsic: Fix minnum and introduce minimumnum (PR #93373)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 01:17:13 PDT 2024
wzssyqa wrote:
> Needs LangRef update and an RFC.
>
> I only briefly looked at this, but I think we can probably get away with just changing minnum to follow IEEE behavior and then make use of the following general rule about our FP operations:
>
RISC-V/Hexagon has IEEE754-2019 `minimumNUMBER` operation only.
Such architectures may get benefits with `ISD::FMINIMUMNUM`.
> > Floating-point math operations are allowed to treat all NaNs as if they were quiet NaNs. For example, “pow(1.0, SNaN)” may be simplified to 1.0.
>
> The effective outcome of this would be that both behaviors become valid. The sNaN -> qNaN case would be the plain intrinsic definition and the sNaN -> other operand case would be via sNaN -> qNaN relaxation.
>
> Only the constrained minnum intrinsics would require precise sNaN/qNaN distinction, as usual.
>
My major concern is C code like
```C
double fmin(double, double);
double f(double a, double b) {
return fmin(a, b);
}
```
This code may expect the same behavior as libc's fmin(3), while we convert it to `llvm.minnum.f64`.
It may break something.
> I think this would be in the spirit of the general FP handling in LLVM.
https://github.com/llvm/llvm-project/pull/93373
More information about the llvm-commits
mailing list