[llvm] [ConstantFold] Fold `tgamma` and `tgammaf` when the input parameter is a constant value. (PR #114065)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 17:50:32 PDT 2024


================
@@ -2417,6 +2418,15 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
       if (TLI->has(Func))
         return ConstantFoldFP(erf, APF, Ty);
       break;
+    case LibFunc_tgamma:
+    case LibFunc_tgammaf:
+      // NOTE: These boundaries are somewhat conservative.
+      if (TLI->has(Func) && (Ty->isDoubleTy() && (APF > APFloat(1 / DBL_MAX) &&
+                                                  APF < APFloat(171.0)) ||
+                             Ty->isFloatTy() && (APF > APFloat(1 / FLT_MAX) &&
+                                                 APF < APFloat(35.0f))))
----------------
c8ef wrote:

https://github.com/llvm/llvm-project/blob/8c345ecd7c33df5802224e9b97e76f0f48ee9b57/llvm/test/Transforms/InstCombine/tgamma.ll#L20-L36

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


More information about the llvm-commits mailing list