Skip to content

Commit 5dcd666

Browse files
committed
InstSimplify: Handle exp10(log10(x)) -> x
Copy from exp/exp2 case. https://reviews.llvm.org/D157894
1 parent ee8d1d2 commit 5dcd666

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6154,6 +6154,12 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
61546154
match(Op0, m_Intrinsic<Intrinsic::log2>(m_Value(X))))
61556155
return X;
61566156
break;
6157+
case Intrinsic::exp10:
6158+
// exp10(log10(x)) -> x
6159+
if (Q.CxtI->hasAllowReassoc() &&
6160+
match(Op0, m_Intrinsic<Intrinsic::log10>(m_Value(X))))
6161+
return X;
6162+
break;
61576163
case Intrinsic::log:
61586164
// log(exp(x)) -> x
61596165
if (Q.CxtI->hasAllowReassoc() &&

llvm/test/Transforms/InstSimplify/log-exp-intrinsic.ll

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ define double @log10_exp10_log10_exp10_reassoc(double %a) {
240240

241241
define double @exp10_reassoc_log10_strict(double %a) {
242242
; CHECK-LABEL: @exp10_reassoc_log10_strict(
243-
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log10.f64(double [[A:%.*]])
244-
; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.exp10.f64(double [[TMP1]])
245-
; CHECK-NEXT: ret double [[TMP2]]
243+
; CHECK-NEXT: ret double [[A:%.*]]
246244
;
247245
%1 = call double @llvm.log10.f64(double %a)
248246
%2 = call reassoc double @llvm.exp10.f64(double %1)
@@ -277,11 +275,7 @@ define double @exp10_log10_exp10_log10(double %a) {
277275

278276
define double @exp10_log10_exp10_log10_reassoc(double %a) {
279277
; CHECK-LABEL: @exp10_log10_exp10_log10_reassoc(
280-
; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log10.f64(double [[A:%.*]])
281-
; CHECK-NEXT: [[TMP2:%.*]] = call reassoc double @llvm.exp10.f64(double [[TMP1]])
282-
; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.log10.f64(double [[TMP2]])
283-
; CHECK-NEXT: [[TMP4:%.*]] = call reassoc double @llvm.exp10.f64(double [[TMP3]])
284-
; CHECK-NEXT: ret double [[TMP4]]
278+
; CHECK-NEXT: ret double [[A:%.*]]
285279
;
286280
%1 = call double @llvm.log10.f64(double %a)
287281
%2 = call reassoc double @llvm.exp10.f64(double %1)

0 commit comments

Comments
 (0)