[llvm] 8bbc5e1 - [LV] Add test with dead induction in vector loop used outside.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 02:39:28 PST 2022
Author: Florian Hahn
Date: 2022-02-28T10:39:08Z
New Revision: 8bbc5e172a5bc4f76ed8a483ec424a0c6611ab6a
URL: https://github.com/llvm/llvm-project/commit/8bbc5e172a5bc4f76ed8a483ec424a0c6611ab6a
DIFF: https://github.com/llvm/llvm-project/commit/8bbc5e172a5bc4f76ed8a483ec424a0c6611ab6a.diff
LOG: [LV] Add test with dead induction in vector loop used outside.
Add test with a induction phi that is not used in the vector loop, but
by an lcssa phi in the loop exit.
Added:
Modified:
llvm/test/Transforms/LoopVectorize/iv_outside_user.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopVectorize/iv_outside_user.ll b/llvm/test/Transforms/LoopVectorize/iv_outside_user.ll
index a296048cfa3e..373aa9b0a535 100644
--- a/llvm/test/Transforms/LoopVectorize/iv_outside_user.ll
+++ b/llvm/test/Transforms/LoopVectorize/iv_outside_user.ll
@@ -1,5 +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
+; RUN: opt -S -loop-vectorize -force-vector-interleave=1 -force-vector-width=2 < %s | FileCheck --check-prefixes=CHECK,VEC %s
+; RUN: opt -S -loop-vectorize -force-vector-interleave=2 -force-vector-width=1 < %s | FileCheck --check-prefixes=CHECK,INTERLEAVE %s
; CHECK-LABEL: @postinc
; CHECK-LABEL: scalar.ph:
@@ -198,3 +198,42 @@ exit:
%iv.lcssa = phi i64 [ %iv, %loop ]
ret i64 %iv.lcssa
}
+
+
+; %iv.2 is dead in the vector loop and only used outside the loop.
+define i32 @iv_2_dead_in_loop_only_used_outside(i64* %ptr) {
+; CHECK-LABEL: @iv_2_dead_in_loop_only_used_outside
+; CHECK-LABEL: vector.body:
+; CHECK-NEXT: [[INDEX:%.+]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.+]], %vector.body ]
+; VEC-NEXT: [[VEC_IND:%.+]] = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ [[VEC_IND_NEXT:%.+]], %vector.body ]
+; CHECK-NEXT: [[IV_0:%.+]] = add i64 [[INDEX]], 0
+; CHECK-NEXT: [[IV_1:%.+]] = add i64 [[INDEX]], 1
+; CHECK-NEXT: [[INDEX_TRUNC:%.+]] = trunc i64 [[INDEX]] to i32
+; CHECK-NEXT: [[IV_2_OFFSET:%.+]] = mul i32 [[INDEX_TRUNC]], 2
+; CHECK-NEXT: [[IV_2_0:%.+]] = add i32 %offset.idx, 0
+; INTERLEAVE-NEXT: [[IV_2_1:%.+]] = add i32 %offset.idx, 2
+; CHECK-NOT: [[IV_2_0]]
+; INTERLEAVE-NOT: [[IV_2_1]]
+; CHECK-LABEL: scalar.ph:
+; CHECK-NEXT: {{.+}} = phi i64 [ 1002, %middle.block ], [ 0, %entry ]
+; CHECK-NEXT: {{.+}} = phi i32 [ 2004, %middle.block ], [ 0, %entry ]
+; CHECK-LABEL: exit:
+; CHECK-NEXT: %iv.2.lcssa = phi i32 [ %iv.2, %loop ], [ 2002, %middle.block ]
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %iv.2 = phi i32 [ 0, %entry ], [ %iv.2.next, %loop ]
+ %iv.next = add nuw i64 %iv, 1
+ %iv.2.next = add nuw i32 %iv.2, 2
+ %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.2.lcssa = phi i32 [ %iv.2, %loop ]
+ ret i32 %iv.2.lcssa
+}
More information about the llvm-commits
mailing list