[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
Thu Oct 31 07:10:24 PDT 2024


================
@@ -2417,6 +2418,14 @@ 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(DBL_MIN) && APF < APFloat(171.0) ||
----------------
c8ef wrote:

Note that `1 / DBL_MAX < DBL_MIN`, and we don't want to constant fold subnormal floating point as a parameter. I believe using MIN will be sufficient.

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


More information about the llvm-commits mailing list