Skip to content

Commit 7b19cec

Browse files
committed
!Fxiup address comments, thanks
1 parent 03203ae commit 7b19cec

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7321,8 +7321,9 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
73217321
if (BasicBlock *SCEVCheckBlock = ILV.RTChecks.getSCEVChecks().second)
73227322
SCEVCheckBlock->moveAfter(EntryBB);
73237323

7324+
MDNode *LID = OrigLoop->getLoopID();
73247325
std::optional<MDNode *> VectorizedLoopID = makeFollowupLoopID(
7325-
OrigLoop->getLoopID(),
7326+
LID,
73267327
{LLVMLoopVectorizeFollowupAll, LLVMLoopVectorizeFollowupVectorized});
73277328

73287329
BestVPlan.execute(&State);
@@ -7363,10 +7364,8 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
73637364
} else {
73647365
// Keep all loop hints from the original loop on the vector loop (we'll
73657366
// replace the vectorizer-specific hints below).
7366-
if (BestVPlan.getScalarPreheader()->hasPredecessors()) {
7367-
if (MDNode *LID = OrigLoop->getLoopID())
7368-
L->setLoopID(LID);
7369-
}
7367+
if (LID)
7368+
L->setLoopID(LID);
73707369

73717370
LoopVectorizeHints Hints(L, true, *ORE);
73727371
Hints.setAlreadyVectorized();

llvm/test/Transforms/LoopVectorize/hints-trans.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ define void @scalar_loop_dead_after_vectorization(ptr nocapture %b) {
1515
; CHECK-NEXT: store <4 x i32> splat (i32 1), ptr [[TMP0]], align 4
1616
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
1717
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[INDEX_NEXT]], 16
18+
; CHECK-NEXT: br i1 [[TMP1]], label %[[EXIT:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
19+
; CHECK: [[EXIT]]:
1820
; CHECK-NEXT: ret void
1921
;
2022
entry:

llvm/test/Transforms/LoopVectorize/single_early_exit_with_outer_loop.ll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
21
; RUN: opt -S < %s -passes='loop-vectorize,verify<loops>,print<loops>' -disable-output 2>&1 | FileCheck %s
32

43
declare void @init_mem(ptr, i64);
54

65
; Tests that the additional middle.split created for handling loops with
76
; uncountable early exits is correctly adding to the outer loop at depth 1.
87
define void @early_exit_in_outer_loop1() {
8+
; CHECK-LABEL: Loop info for function 'early_exit_in_outer_loop1':
9+
; CHECK: Loop at depth 1 containing: %loop.outer<header>,%loop.inner.found,%loop.inner.end<latch>,%loop.inner.end.loopexit,%vector.ph,%vector.body,%middle.split,%middle.block,%vector.early.exit
910
entry:
1011
%p1 = alloca [1024 x i8]
1112
%p2 = alloca [1024 x i8]
@@ -43,6 +44,9 @@ loop.inner.end:
4344
; uncountable early exits is correctly adding to both the outer and middle
4445
; loops at depths 1 and 2, respectively.
4546
define void @early_exit_in_outer_loop2() {
47+
; CHECK-LABEL: Loop info for function 'early_exit_in_outer_loop2':
48+
; CHECK: Loop at depth 1 containing: %loop.outer<header>,%loop.middle,%loop.inner.found,%loop.inner.end,%loop.middle.end,%loop.outer.latch<latch>,%vector.ph,%vector.body,%middle.split,%middle.block,%vector.early.exit
49+
; CHECK: Loop at depth 2 containing: %loop.middle<header>,%loop.inner.end<latch><exiting>,%vector.ph,%vector.body,%middle.split<exiting>,%middle.block
4650
entry:
4751
%p1 = alloca [1024 x i8]
4852
%p2 = alloca [1024 x i8]
@@ -87,6 +91,9 @@ loop.outer.latch:
8791
}
8892

8993
define i32 @early_exit_branch_to_outer_header() {
94+
; CHECK-LABEL: Loop info for function 'early_exit_branch_to_outer_header':
95+
; CHECK-NEXT: Loop at depth 1 containing: %outer.header<header>,%outer.header.loopexit<latch>,%vector.ph,%vector.body,%middle.split<exiting>,%vector.early.exit
96+
; CHECK-NEXT: Loop at depth 2 containing: %vector.body<header><latch><exiting>
9097
entry:
9198
%src = alloca [1024 x i8]
9299
call void @init_mem(ptr %src, i64 1024)
@@ -110,5 +117,3 @@ loop.latch:
110117
exit:
111118
ret i32 1
112119
}
113-
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
114-
; CHECK: {{.*}}

0 commit comments

Comments
 (0)