Author: c8ef Date: 2024-11-01T09:25:43+08:00 New Revision: 8b1b4753ac16cba5a153536171a243d76300e4bb
URL: https://github.com/llvm/llvm-project/commit/8b1b4753ac16cba5a153536171a243d76300e4bb DIFF: https://github.com/llvm/llvm-project/commit/8b1b4753ac16cba5a153536171a243d76300e4bb.diff LOG: Revert "[ConstantFold] Fold `tgamma` and `tgammaf` when the input parameter i…" This reverts commit 1f07f995cc994dfb46b65fe97986efca15cf304b. Added: Modified: llvm/lib/Analysis/ConstantFolding.cpp Removed: llvm/test/Transforms/InstCombine/tgamma.ll ################################################################################ diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index a96c3bebba790e..c5a2c2f52f8dc2 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -57,7 +57,6 @@ #include <cassert> #include <cerrno> #include <cfenv> -#include <cfloat> #include <cmath> #include <cstdint> @@ -1699,9 +1698,9 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) { Name == "sinh" || Name == "sinhf" || Name == "sqrt" || Name == "sqrtf"; case 't': - return Name == "tan" || Name == "tanf" || Name == "tanh" || - Name == "tanhf" || Name == "trunc" || Name == "truncf" || - Name == "tgamma" || Name == "tgammaf"; + return Name == "tan" || Name == "tanf" || + Name == "tanh" || Name == "tanhf" || + Name == "trunc" || Name == "truncf"; case '_': // Check for various function names that get used for the math functions // when the header files are preprocessed with the macro @@ -2418,14 +2417,6 @@ 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) || - Ty->isFloatTy() && APF > APFloat(FLT_MIN) && APF < APFloat(35.0f))) - return ConstantFoldFP(tgamma, APF, Ty); - break; case LibFunc_nearbyint: case LibFunc_nearbyintf: case LibFunc_rint: @@ -3638,10 +3629,6 @@ bool llvm::isMathLibCallNoop(const CallBase *Call, case LibFunc_sqrtf: return Op.isNaN() || Op.isZero() || !Op.isNegative(); - case LibFunc_tgamma: - case LibFunc_tgammaf: - return true; - // FIXME: Add more functions: sqrt_finite, atanh, expm1, log1p, // maybe others? default: diff --git a/llvm/test/Transforms/InstCombine/tgamma.ll b/llvm/test/Transforms/InstCombine/tgamma.ll deleted file mode 100644 index dd74617fee83e5..00000000000000 --- a/llvm/test/Transforms/InstCombine/tgamma.ll +++ /dev/null @@ -1,255 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 -; RUN: opt < %s -passes=instcombine -S | FileCheck %s - -define float @tgammaf_in_range() { -; CHECK-LABEL: define float @tgammaf_in_range() { -; CHECK-NEXT: ret float 0x479A216280000000 -; - %r = call float @tgammaf(float 34.0) - ret float %r -} - -define double @tgamma_in_range() { -; CHECK-LABEL: define double @tgamma_in_range() { -; CHECK-NEXT: ret double 0x605166C698CF183B -; - %r = call double @tgamma(double 100.0) - ret double %r -} - -define float @tgammaf_const_left_range() { -; CHECK-LABEL: define float @tgammaf_const_left_range() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0x3810000000000000) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0x3810000000000000) - ret float %r -} - -define double @tgamma_const_left_range() { -; CHECK-LABEL: define double @tgamma_const_left_range() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0x10000000000000) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0x0010000000000000) - ret double %r -} - -define float @tgammaf_const_right_range() { -; CHECK-LABEL: define float @tgammaf_const_right_range() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 3.600000e+01) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 36.0) - ret float %r -} - -define double @tgamma_const_right_range() { -; CHECK-LABEL: define double @tgamma_const_right_range() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 1.720000e+02) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 172.0) - ret double %r -} - -define float @tgammaf_minus_one() { -; CHECK-LABEL: define float @tgammaf_minus_one() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float -1.000000e+00) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float -1.000000e+00) - ret float %r -} - -define double @tgamma_minus_one() { -; CHECK-LABEL: define double @tgamma_minus_one() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double -1.000000e+00) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double -1.000000e+00) - ret double %r -} - -define float @tgammaf_minus_one_memory_none() { -; CHECK-LABEL: define float @tgammaf_minus_one_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float -1.000000e+00) #[[ATTR1:[0-9]+]] -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float -1.000000e+00) readnone - ret float %r -} - -define double @tgamma_minus_one_memory_none() { -; CHECK-LABEL: define double @tgamma_minus_one_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double -1.000000e+00) #[[ATTR1]] -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double -1.000000e+00) readnone - ret double %r -} - -define float @tgammaf_zero() { -; CHECK-LABEL: define float @tgammaf_zero() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0.000000e+00) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0.000000e+00) - ret float %r -} - -define double @tgamma_zero() { -; CHECK-LABEL: define double @tgamma_zero() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0.000000e+00) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0.000000e+00) - ret double %r -} - -define float @tgammaf_neg_zero() { -; CHECK-LABEL: define float @tgammaf_neg_zero() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float -0.000000e+00) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float -0.000000e+00) - ret float %r -} - -define double @tgamma_neg_zero() { -; CHECK-LABEL: define double @tgamma_neg_zero() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double -0.000000e+00) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double -0.000000e+00) - ret double %r -} - -define float @tgammaf_inf() { -; CHECK-LABEL: define float @tgammaf_inf() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0x7FF0000000000000) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0x7FF0000000000000) - ret float %r -} - -define double @tgamma_inf() { -; CHECK-LABEL: define double @tgamma_inf() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0x7FF0000000000000) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0x7FF0000000000000) - ret double %r -} - -define float @tgammaf_inf_memory_none() { -; CHECK-LABEL: define float @tgammaf_inf_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0x7FF0000000000000) #[[ATTR1]] -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0x7FF0000000000000) readnone - ret float %r -} - -define double @tgamma_inf_memory_none() { -; CHECK-LABEL: define double @tgamma_inf_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0x7FF0000000000000) #[[ATTR1]] -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0x7FF0000000000000) readnone - ret double %r -} - -define float @tgammaf_neg_inf() { -; CHECK-LABEL: define float @tgammaf_neg_inf() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0xFFF0000000000000) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0xFFF0000000000000) - ret float %r -} - -define double @tgamma_neg_inf() { -; CHECK-LABEL: define double @tgamma_neg_inf() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0xFFF0000000000000) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0xFFF0000000000000) - ret double %r -} - -define float @tgammaf_neg_inf_memory_none() { -; CHECK-LABEL: define float @tgammaf_neg_inf_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0xFFF0000000000000) #[[ATTR1]] -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0xFFF0000000000000) readnone - ret float %r -} - -define double @tgamma_neg_inf_memory_none() { -; CHECK-LABEL: define double @tgamma_neg_inf_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0xFFF0000000000000) #[[ATTR1]] -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0xFFF0000000000000) readnone - ret double %r -} - -define float @tgammaf_nan() { -; CHECK-LABEL: define float @tgammaf_nan() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0x7FF8000000000000) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0x7FF8000000000000) - ret float %r -} - -define double @tgamma_nan() { -; CHECK-LABEL: define double @tgamma_nan() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0x7FF8000000000000) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0x7FF8000000000000) - ret double %r -} - -define float @tgammaf_nan_memory_none() { -; CHECK-LABEL: define float @tgammaf_nan_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float 0x7FF8000000000000) #[[ATTR1]] -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float 0x7FF8000000000000) readnone - ret float %r -} - -define double @tgamma_nan_memory_none() { -; CHECK-LABEL: define double @tgamma_nan_memory_none() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double 0x7FF8000000000000) #[[ATTR1]] -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double 0x7FF8000000000000) readnone - ret double %r -} - -define float @tgammaf_poison() { -; CHECK-LABEL: define float @tgammaf_poison() { -; CHECK-NEXT: [[R:%.*]] = call float @tgammaf(float poison) -; CHECK-NEXT: ret float [[R]] -; - %r = call float @tgammaf(float poison) - ret float %r -} - -define double @tgamma_poison() { -; CHECK-LABEL: define double @tgamma_poison() { -; CHECK-NEXT: [[R:%.*]] = call double @tgamma(double poison) -; CHECK-NEXT: ret double [[R]] -; - %r = call double @tgamma(double poison) - ret double %r -} - -declare float @tgammaf(float) willreturn -declare double @tgamma(double) willreturn _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits