[llvm] aa158bf - [LV] Update tests to replace some code with loop varying instructions.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 06:13:18 PDT 2024


Author: Florian Hahn
Date: 2024-09-09T14:10:12+01:00
New Revision: aa158bf40285925d3c019d9e697cd2c88421297a

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

LOG: [LV] Update tests to replace some code with loop varying instructions.

Update some tests with loop-invariant instructions, where hoisting them
out of the loop changes the vectorization decision. This should preserve
their original spirit when making further improvements.

Added: 
    

Modified: 
    llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll
    llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll b/llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll
index 4eba40ff91f009..f90524fde79654 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll
@@ -126,9 +126,9 @@ exit:
   ret void
 }
 
-define void @call_scalarized(ptr noalias %src, ptr noalias %dst, double %0) {
+define void @call_scalarized(ptr noalias %src, ptr noalias %dst) {
 ; CHECK-LABEL: define void @call_scalarized(
-; CHECK-SAME: ptr noalias [[SRC:%.*]], ptr noalias [[DST:%.*]], double [[TMP0:%.*]]) {
+; CHECK-SAME: ptr noalias [[SRC:%.*]], ptr noalias [[DST:%.*]]) {
 ; CHECK-NEXT:  [[ENTRY:.*]]:
 ; CHECK-NEXT:    br label %[[LOOP_HEADER:.*]]
 ; CHECK:       [[LOOP_HEADER]]:
@@ -136,7 +136,7 @@ define void @call_scalarized(ptr noalias %src, ptr noalias %dst, double %0) {
 ; CHECK-NEXT:    [[IV_NEXT]] = add i64 [[IV]], -1
 ; CHECK-NEXT:    [[GEP_SRC:%.*]] = getelementptr double, ptr [[SRC]], i64 [[IV_NEXT]]
 ; CHECK-NEXT:    [[L:%.*]] = load double, ptr [[GEP_SRC]], align 8
-; CHECK-NEXT:    [[CMP295:%.*]] = fcmp ugt double [[TMP0]], 0.000000e+00
+; CHECK-NEXT:    [[CMP295:%.*]] = fcmp une double [[L]], 4.000000e+00
 ; CHECK-NEXT:    [[CMP299:%.*]] = fcmp ugt double [[L]], 0.000000e+00
 ; CHECK-NEXT:    [[OR_COND:%.*]] = or i1 [[CMP295]], [[CMP299]]
 ; CHECK-NEXT:    br i1 [[OR_COND]], label %[[LOOP_LATCH]], label %[[THEN:.*]]
@@ -159,7 +159,7 @@ loop.header:
   %iv.next = add i64 %iv, -1
   %gep.src = getelementptr double, ptr %src, i64 %iv.next
   %l = load double, ptr %gep.src, align 8
-  %cmp295 = fcmp ugt double %0, 0.000000e+00
+  %cmp295 = fcmp une double %l, 4.000000e+00
   %cmp299 = fcmp ugt double %l, 0.000000e+00
   %or.cond = or i1 %cmp295, %cmp299
   br i1 %or.cond, label %loop.latch, label %then

diff  --git a/llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll b/llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll
index ff5cf3a1394d5e..cb1ac49986f68c 100644
--- a/llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll
+++ b/llvm/test/Transforms/LoopVectorize/vector-intrinsic-call-cost.ll
@@ -4,7 +4,10 @@
 ; CHECK-LABEL: vector.body:
 ; CHECK-NEXT:    [[IDX:%.+]] = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
 ; CHECK-NEXT:    [[IDX0:%.+]] = add i32 %index, 0
-; CHECK-NEXT:    [[FSHL:%.+]] = call <4 x i16> @llvm.fshl.v4i16(<4 x i16> undef, <4 x i16> undef, <4 x i16> <i16 15, i16 15, i16 15, i16 15>)
+; CHECK-NEXT:    [[GEP:%.+]] = getelementptr inbounds i16, ptr %src, i32 [[IDX0]]
+; CHECK-NEXT:    [[GEP0:%.+]] = getelementptr inbounds i16, ptr [[GEP]], i32 0
+; CHECK-NEXT:    [[WIDE_LOAD:%.+]] = load <4 x i16>, ptr [[GEP0]], align 2
+; CHECK-NEXT:    [[FSHL:%.+]] = call <4 x i16> @llvm.fshl.v4i16(<4 x i16> [[WIDE_LOAD]], <4 x i16> [[WIDE_LOAD]], <4 x i16> <i16 15, i16 15, i16 15, i16 15>)
 ; CHECK-NEXT:    [[GEP0:%.+]] = getelementptr inbounds i16, ptr %dst, i32 [[IDX0]]
 ; CHECK-NEXT:    [[GEP1:%.+]] = getelementptr inbounds i16, ptr [[GEP0]], i32 0
 ; CHECK-NEXT:    store <4 x i16> [[FSHL]], ptr [[GEP1]], align 2
@@ -12,7 +15,7 @@
 ; CHECK-NEXT:    [[EC:%.+]] = icmp eq i32 [[IDX_NEXT]], %n.vec
 ; CHECK-NEXT:    br i1 [[EC]], label %middle.block, label %vector.body
 ;
-define void @test_fshl(i32 %width, ptr %dst) {
+define void @test_fshl(i32 %width, ptr %dst, ptr %src) {
 entry:
   br label %for.body9.us.us
 
@@ -21,7 +24,9 @@ for.cond6.for.cond.cleanup8_crit_edge.us.us:      ; preds = %for.body9.us.us
 
 for.body9.us.us:                                  ; preds = %for.body9.us.us, %entry
   %iv = phi i32 [ 0, %entry ], [ %iv.next, %for.body9.us.us ]
-  %conv4.i.us.us = tail call i16 @llvm.fshl.i16(i16 undef, i16 undef, i16 15)
+  %gep = getelementptr inbounds i16, ptr %src, i32 %iv
+  %l = load i16, ptr %gep
+  %conv4.i.us.us = tail call i16 @llvm.fshl.i16(i16 %l, i16 %l, i16 15)
   %dst.gep = getelementptr inbounds i16, ptr %dst, i32 %iv
   store i16 %conv4.i.us.us, ptr %dst.gep
   %iv.next = add nuw i32 %iv, 1


        


More information about the llvm-commits mailing list