[llvm] f03f494 - [InstCombine] add tests for pow() reassociation; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 07:16:18 PDT 2021


Author: Sanjay Patel
Date: 2021-06-04T10:16:07-04:00
New Revision: f03f4944cf829c86bc2c080b9a564bbc59aad277

URL: https://github.com/llvm/llvm-project/commit/f03f4944cf829c86bc2c080b9a564bbc59aad277
DIFF: https://github.com/llvm/llvm-project/commit/f03f4944cf829c86bc2c080b9a564bbc59aad277.diff

LOG: [InstCombine] add tests for pow() reassociation; NFC

Baseline tests for D102574

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/fmul-pow.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/fmul-pow.ll b/llvm/test/Transforms/InstCombine/fmul-pow.ll
index 7a0206272695..6e23f7764c60 100644
--- a/llvm/test/Transforms/InstCombine/fmul-pow.ll
+++ b/llvm/test/Transforms/InstCombine/fmul-pow.ll
@@ -2,6 +2,7 @@
 ; RUN: opt -S -instcombine < %s | FileCheck %s
 
 declare double @llvm.pow.f64(double, double)
+declare void @use(double)
 
 define double @pow_ab_a(double %a, double %b)  {
 ; CHECK-LABEL: @pow_ab_a(
@@ -88,3 +89,60 @@ define double @pow_ab_x_pow_ac_reassoc(double %a, double %b, double %c) {
   %mul = fmul reassoc double %2, %1
   ret double %mul
 }
+
+
+define double @pow_ab_reassoc(double %a, double %b) {
+; CHECK-LABEL: @pow_ab_reassoc(
+; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[TMP1]], [[TMP1]]
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %1 = call double @llvm.pow.f64(double %a, double %b)
+  %mul = fmul reassoc double %1, %1
+  ret double %mul
+}
+
+define double @pow_ab_reassoc_extra_use(double %a, double %b) {
+; CHECK-LABEL: @pow_ab_reassoc_extra_use(
+; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[TMP1]], [[TMP1]]
+; CHECK-NEXT:    call void @use(double [[TMP1]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %1 = call double @llvm.pow.f64(double %a, double %b)
+  %mul = fmul reassoc double %1, %1
+  call void @use(double %1)
+  ret double %mul
+}
+
+define double @pow_ab_x_pow_ac_reassoc_extra_use(double %a, double %b, double %c) {
+; CHECK-LABEL: @pow_ab_x_pow_ac_reassoc_extra_use(
+; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[TMP2:%.*]] = call double @llvm.pow.f64(double [[A]], double [[C:%.*]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    call void @use(double [[TMP1]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %1 = call double @llvm.pow.f64(double %a, double %b)
+  %2 = call double @llvm.pow.f64(double %a, double %c)
+  %mul = fmul reassoc double %1, %2
+  call void @use(double %1)
+  ret double %mul
+}
+
+define double @pow_ab_x_pow_ac_reassoc_multiple_uses(double %a, double %b, double %c) {
+; CHECK-LABEL: @pow_ab_x_pow_ac_reassoc_multiple_uses(
+; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[TMP2:%.*]] = call double @llvm.pow.f64(double [[A]], double [[C:%.*]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    call void @use(double [[TMP1]])
+; CHECK-NEXT:    call void @use(double [[TMP2]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %1 = call double @llvm.pow.f64(double %a, double %b)
+  %2 = call double @llvm.pow.f64(double %a, double %c)
+  %mul = fmul reassoc double %1, %2
+  call void @use(double %1)
+  call void @use(double %2)
+  ret double %mul
+}


        


More information about the llvm-commits mailing list