[llvm] [SimplifyLibCalls] Recognize and simplify f[min/max]imumnum (PR #170699)

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 6 00:20:45 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") &&
----------------
valadaptive wrote:

I mostly just adapted this from `optimizeFMinFMax` above. We could indeed pass in the `LibFunc` to both functions, although we still need to get the function name to pass into `hasFloatVersion`.

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


More information about the llvm-commits mailing list