[llvm] 53c06c5 - SimplifyLibCalls: Simplify fp immediate checking code (NFC)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 01:55:23 PDT 2024
Author: Matt Arsenault
Date: 2024-06-13T10:47:35+02:00
New Revision: 53c06c5644f9529057c97620efd8e8f85d0ed605
URL: https://github.com/llvm/llvm-project/commit/53c06c5644f9529057c97620efd8e8f85d0ed605
DIFF: https://github.com/llvm/llvm-project/commit/53c06c5644f9529057c97620efd8e8f85d0ed605.diff
LOG: SimplifyLibCalls: Simplify fp immediate checking code (NFC)
Re-use already queried call arguments and matched APFloat, instead
of re-matching the original argument.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 125e5fa437538..60ea200ad9ff9 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2082,7 +2082,7 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
// Evaluate special cases related to a constant base.
const APFloat *BaseF;
- if (!match(Pow->getArgOperand(0), m_APFloat(BaseF)))
+ if (!match(Base, m_APFloat(BaseF)))
return nullptr;
AttributeList NoAttrs; // Attributes are only meaningful on the original call
@@ -2090,7 +2090,7 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
const bool UseIntrinsic = Pow->doesNotAccessMemory();
// pow(2.0, itofp(x)) -> ldexp(1.0, x)
- if ((UseIntrinsic || !Ty->isVectorTy()) && match(Base, m_SpecificFP(2.0)) &&
+ if ((UseIntrinsic || !Ty->isVectorTy()) && BaseF->isExactlyValue(2.0) &&
(isa<SIToFPInst>(Expo) || isa<UIToFPInst>(Expo)) &&
(UseIntrinsic ||
hasFloatFn(M, TLI, Ty, LibFunc_ldexp, LibFunc_ldexpf, LibFunc_ldexpl))) {
@@ -2137,7 +2137,7 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
}
// pow(10.0, x) -> exp10(x)
- if (match(Base, m_SpecificFP(10.0)) &&
+ if (BaseF->isExactlyValue(10.0) &&
hasFloatFn(M, TLI, Ty, LibFunc_exp10, LibFunc_exp10f, LibFunc_exp10l)) {
if (Pow->doesNotAccessMemory()) {
More information about the llvm-commits
mailing list