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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 12:12:13 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))))
----------------
arsenm wrote:

Tests for at and above these limits? 

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


More information about the llvm-commits mailing list