[llvm] [SimplifyLibCalls] Recognize and simplify f[min/max]imumnum (PR #170699)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 5 07:49:21 PST 2025
================
@@ -2543,6 +2543,30 @@ Value *LibCallSimplifier::optimizeFMinFMax(CallInst *CI, IRBuilderBase &B) {
CI->getArgOperand(1), FMF));
}
+Value *LibCallSimplifier::optimizeFMinimumnumFMaximumnum(CallInst *CI,
+ IRBuilderBase &B) {
+ Module *M = CI->getModule();
+
+ // If we can shrink the call to a float function rather than a double
+ // function, do that first.
+ Function *Callee = CI->getCalledFunction();
+ StringRef Name = Callee->getName();
+ if ((Name == "fminimum_num" || Name == "fmaximum_num") &&
+ hasFloatVersion(M, Name))
+ if (Value *Ret = optimizeBinaryDoubleFP(CI, B, TLI))
+ return Ret;
+
+ // The new fminimum_num/fmaximum_num functions, unlike fmin/fmax, *are*
+ // sensitive to the sigh of zero, so we don't change the fast-math flags like
----------------
dtcxzyw wrote:
```suggestion
// sensitive to the sign of zero, so we don't change the fast-math flags like
```
https://github.com/llvm/llvm-project/pull/170699
More information about the llvm-commits
mailing list