[llvm] [MIPS] Implement llvm.fminimum and llvm.fmaximum with f32/f64 (PR #89907)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 23:18:47 PDT 2024


wzssyqa wrote:

> > Can you have consider it?
> > It's due to that we process the most cases as early as possible.
> 
> preliminary checks are essential since we do not know what value actually is in the operands, and since minnum and maxnum returns other operand if NaN exists, we have to check if there's any NaN in them.
> 
> I have a “slightly better” version in mind, which might handle the edge case. Again, preliminary checks are essential:
> 
> ```
> newx = max(x, y)
> if (newx == x) {
> 	if (y == NaN) {
> 		return y;
> 	}
> 	if (y == 0) {
> 		if (x == -0) return y;
> 		return x;
> 	}
> 	return x;
> }
> return y;
> ```

Maybe it is better for R6, but not for pre-R6.
In fact for R6, we can do it better

```
newx = max(x, y)
if ((x is NaN) or (y is NaN)) {
     return NaN;
}
return newx;
```
max.fmt in R6 can process +0/-0 as `fmaximum` expects.

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


More information about the llvm-commits mailing list