Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -6175,8 +6175,11 @@ break; case Intrinsic::log10: // log10(pow(10.0, x)) -> x + // log10(exp10(x)) -> x if (Q.CxtI->hasAllowReassoc() && - match(Op0, m_Intrinsic(m_SpecificFP(10.0), m_Value(X)))) + (match(Op0, m_Intrinsic(m_Value(X))) || + match(Op0, + m_Intrinsic(m_SpecificFP(10.0), m_Value(X))))) return X; break; case Intrinsic::experimental_vector_reverse: Index: llvm/test/Transforms/InstSimplify/log-exp-intrinsic.ll =================================================================== --- llvm/test/Transforms/InstSimplify/log-exp-intrinsic.ll +++ llvm/test/Transforms/InstSimplify/log-exp-intrinsic.ll @@ -194,9 +194,7 @@ define double @log10_reassoc_exp10_strict(double %a) { ; CHECK-LABEL: @log10_reassoc_exp10_strict( -; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp10.f64(double [[A:%.*]]) -; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.log10.f64(double [[TMP1]]) -; CHECK-NEXT: ret double [[TMP2]] +; CHECK-NEXT: ret double [[A:%.*]] ; %1 = call double @llvm.exp10.f64(double %a) %2 = call reassoc double @llvm.log10.f64(double %1) @@ -231,11 +229,7 @@ define double @log10_exp10_log10_exp10_reassoc(double %a) { ; CHECK-LABEL: @log10_exp10_log10_exp10_reassoc( -; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp10.f64(double [[A:%.*]]) -; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.log10.f64(double [[TMP1]]) -; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp10.f64(double [[TMP2]]) -; CHECK-NEXT: [[TMP4:%.*]] = call reassoc double @llvm.log10.f64(double [[TMP3]]) -; CHECK-NEXT: ret double [[TMP4]] +; CHECK-NEXT: ret double [[A:%.*]] ; %1 = call double @llvm.exp10.f64(double %a) %2 = call reassoc double @llvm.log10.f64(double %1)