Skip to content

Commit 53c06c5

Browse files
committed
SimplifyLibCalls: Simplify fp immediate checking code (NFC)
Re-use already queried call arguments and matched APFloat, instead of re-matching the original argument.
1 parent 453a0e4 commit 53c06c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,15 +2082,15 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
20822082
// Evaluate special cases related to a constant base.
20832083

20842084
const APFloat *BaseF;
2085-
if (!match(Pow->getArgOperand(0), m_APFloat(BaseF)))
2085+
if (!match(Base, m_APFloat(BaseF)))
20862086
return nullptr;
20872087

20882088
AttributeList NoAttrs; // Attributes are only meaningful on the original call
20892089

20902090
const bool UseIntrinsic = Pow->doesNotAccessMemory();
20912091

20922092
// pow(2.0, itofp(x)) -> ldexp(1.0, x)
2093-
if ((UseIntrinsic || !Ty->isVectorTy()) && match(Base, m_SpecificFP(2.0)) &&
2093+
if ((UseIntrinsic || !Ty->isVectorTy()) && BaseF->isExactlyValue(2.0) &&
20942094
(isa<SIToFPInst>(Expo) || isa<UIToFPInst>(Expo)) &&
20952095
(UseIntrinsic ||
20962096
hasFloatFn(M, TLI, Ty, LibFunc_ldexp, LibFunc_ldexpf, LibFunc_ldexpl))) {
@@ -2137,7 +2137,7 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
21372137
}
21382138

21392139
// pow(10.0, x) -> exp10(x)
2140-
if (match(Base, m_SpecificFP(10.0)) &&
2140+
if (BaseF->isExactlyValue(10.0) &&
21412141
hasFloatFn(M, TLI, Ty, LibFunc_exp10, LibFunc_exp10f, LibFunc_exp10l)) {
21422142

21432143
if (Pow->doesNotAccessMemory()) {

0 commit comments

Comments
 (0)