[llvm] 9230d5d - [InstCombine] add tests for pow reassociation; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 10:26:18 PST 2023


Author: Sanjay Patel
Date: 2023-01-13T13:26:10-05:00
New Revision: 9230d5d6a239225fba517b651d5c8d91d216a7c4

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

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

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 a14b834335414..e5226400bb3db 100644
--- a/llvm/test/Transforms/InstCombine/fmul-pow.ll
+++ b/llvm/test/Transforms/InstCombine/fmul-pow.ll
@@ -64,6 +64,53 @@ define double @pow_ab_pow_cb_reassoc(double %a, double %b, double %c) {
   ret double %mul
 }
 
+define double @pow_ab_pow_cb_reassoc_use1(double %a, double %b, double %c) {
+; CHECK-LABEL: @pow_ab_pow_cb_reassoc_use1(
+; CHECK-NEXT:    [[AB:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[CB:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[AB]], [[CB]]
+; CHECK-NEXT:    call void @use(double [[AB]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %ab = call double @llvm.pow.f64(double %a, double %b)
+  %cb = call double @llvm.pow.f64(double %c, double %b)
+  %mul = fmul reassoc double %ab, %cb
+  call void @use(double %ab)
+  ret double %mul
+}
+
+define double @pow_ab_pow_cb_reassoc_use2(double %a, double %b, double %c) {
+; CHECK-LABEL: @pow_ab_pow_cb_reassoc_use2(
+; CHECK-NEXT:    [[AB:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[CB:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[AB]], [[CB]]
+; CHECK-NEXT:    call void @use(double [[CB]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %ab = call double @llvm.pow.f64(double %a, double %b)
+  %cb = call double @llvm.pow.f64(double %c, double %b)
+  %mul = fmul reassoc double %ab, %cb
+  call void @use(double %cb)
+  ret double %mul
+}
+
+define double @pow_ab_pow_cb_reassoc_use3(double %a, double %b, double %c) {
+; CHECK-LABEL: @pow_ab_pow_cb_reassoc_use3(
+; CHECK-NEXT:    [[AB:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
+; CHECK-NEXT:    [[CB:%.*]] = call double @llvm.pow.f64(double [[C:%.*]], double [[B]])
+; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc double [[AB]], [[CB]]
+; CHECK-NEXT:    call void @use(double [[AB]])
+; CHECK-NEXT:    call void @use(double [[CB]])
+; CHECK-NEXT:    ret double [[MUL]]
+;
+  %ab = call double @llvm.pow.f64(double %a, double %b)
+  %cb = call double @llvm.pow.f64(double %c, double %b)
+  %mul = fmul reassoc double %ab, %cb
+  call void @use(double %ab)
+  call void @use(double %cb)
+  ret double %mul
+}
+
 define double @pow_ab_pow_ac(double %a, double %b, double %c) {
 ; CHECK-LABEL: @pow_ab_pow_ac(
 ; CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.pow.f64(double [[A:%.*]], double [[B:%.*]])
@@ -80,8 +127,8 @@ define double @pow_ab_pow_ac(double %a, double %b, double %c) {
 define double @pow_ab_x_pow_ac_reassoc(double %a, double %b, double %c) {
 ; CHECK-LABEL: @pow_ab_x_pow_ac_reassoc(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fadd reassoc double [[C:%.*]], [[B:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
-; CHECK-NEXT:    ret double [[TMP2]]
+; CHECK-NEXT:    [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], 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)
@@ -92,8 +139,8 @@ define double @pow_ab_x_pow_ac_reassoc(double %a, double %b, double %c) {
 define double @pow_ab_reassoc(double %a, double %b) {
 ; CHECK-LABEL: @pow_ab_reassoc(
 ; CHECK-NEXT:    [[TMP1:%.*]] = fadd reassoc double [[B:%.*]], [[B]]
-; CHECK-NEXT:    [[TMP2:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
-; CHECK-NEXT:    ret double [[TMP2]]
+; CHECK-NEXT:    [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A:%.*]], double [[TMP1]])
+; CHECK-NEXT:    ret double [[MUL]]
 ;
   %1 = call double @llvm.pow.f64(double %a, double %b)
   %mul = fmul reassoc double %1, %1
@@ -117,9 +164,9 @@ 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:%.*]] = fadd reassoc double [[B]], [[C:%.*]]
-; CHECK-NEXT:    [[TMP3:%.*]] = call reassoc double @llvm.pow.f64(double [[A]], double [[TMP2]])
+; CHECK-NEXT:    [[MUL:%.*]] = call reassoc double @llvm.pow.f64(double [[A]], double [[TMP2]])
 ; CHECK-NEXT:    call void @use(double [[TMP1]])
-; CHECK-NEXT:    ret double [[TMP3]]
+; 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)


        


More information about the llvm-commits mailing list