[LV] Add test with IV that needs scalar steps and user outside of loop.
authorFlorian Hahn <flo@fhahn.com>
Mon, 28 Feb 2022 09:46:18 +0000 (09:46 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 28 Feb 2022 09:46:18 +0000 (09:46 +0000)
Also add a run line to check interleaving only. This test covers the PPC
buildbot failures caused by 49b23f451cf71.

llvm/test/Transforms/LoopVectorize/iv_outside_user.ll

index e438594..a296048 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: opt -S -loop-vectorize -force-vector-interleave=1 -force-vector-width=2 < %s | FileCheck %s
+; RUN: opt -S -loop-vectorize -force-vector-interleave=2 -force-vector-width=1 < %s | FileCheck %s
 
 ; CHECK-LABEL: @postinc
 ; CHECK-LABEL: scalar.ph:
@@ -174,3 +175,26 @@ BB4:
   %tmp15 = icmp sgt i32 %tmp14, 0
   br i1 %tmp15, label %BB4, label %BB1
 }
+
+; CHECK-LABEL: @iv_scalar_steps_and_outside_users
+; CHECK-LABEL: scalar.ph:
+; CHECK-NEXT:    %bc.resume.val = phi i64 [ 1002, %middle.block ], [ 0, %entry ]
+; CHECK-LABEL: exit:
+; CHECK-NEXT:    %iv.lcssa = phi i64 [ %iv, %loop ], [ 1001, %middle.block ]
+;
+define i64 @iv_scalar_steps_and_outside_users(i64* %ptr) {
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.next = add nuw i64 %iv, 1
+  %gep.ptr = getelementptr inbounds i64, i64* %ptr, i64 %iv
+  store i64 %iv, i64* %gep.ptr
+  %exitcond = icmp ugt i64 %iv, 1000
+  br i1 %exitcond, label %exit, label %loop
+
+exit:
+  %iv.lcssa = phi i64 [ %iv, %loop ]
+  ret i64 %iv.lcssa
+}