Skip to content

Commit 00dea4a

Browse files
committed
!fixup add dbg message
1 parent 2042a43 commit 00dea4a

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,10 +1375,17 @@ bool LoopVectorizationLegality::isFixedOrderRecurrence(
13751375
}
13761376

13771377
bool LoopVectorizationLegality::blockNeedsPredication(BasicBlock *BB) const {
1378-
// When vectorizing early exits, create predicates for all blocks, except the
1379-
// header.
1380-
if (hasUncountableEarlyExit() && BB != TheLoop->getHeader())
1381-
return true;
1378+
// When vectorizing early exits, create predicates for the latch block. The
1379+
// early exiting block must be a direct predecessor of the latch at the
1380+
// moment.
1381+
BasicBlock *Latch = TheLoop->getLoopLatch();
1382+
if (hasUncountableEarlyExit()) {
1383+
assert(
1384+
getUncountableExitingBlocks().size() == 1 &&
1385+
is_contained(predecessors(Latch), getUncountableExitingBlocks()[0]) &&
1386+
"Uncountable exiting block must be a direct predecessor of latch");
1387+
return BB == Latch;
1388+
}
13821389
return LoopAccessInfo::blockNeedsPredication(BB, TheLoop, DT);
13831390
}
13841391

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9239,8 +9239,13 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
92399239
SetVector<VPIRInstruction *> ExitUsersToFix = collectUsersInExitBlocks(
92409240
OrigLoop, RecipeBuilder, *Plan, Legal->getInductionVars());
92419241
addExitUsersForFirstOrderRecurrences(*Plan, ExitUsersToFix);
9242-
if (!addUsersInExitBlocks(*Plan, ExitUsersToFix))
9242+
if (!addUsersInExitBlocks(*Plan, ExitUsersToFix)) {
9243+
reportVectorizationFailure(
9244+
"Some exit values in loop with uncountable exit not supported yet",
9245+
"Some exit values in loop with uncountable exit not supported yet",
9246+
"UncountableEarlyExitLoopsUnsupportedExitValue", ORE, OrigLoop);
92439247
return nullptr;
9248+
}
92449249

92459250
// ---------------------------------------------------------------------------
92469251
// Transform initial VPlan: Apply previously taken decisions, in order, to

llvm/test/Transforms/LoopVectorize/early_exit_legality.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define i32 @diff_exit_block_needs_scev_check(i32 %end) {
1111
; CHECK-LABEL: LV: Checking a loop in 'diff_exit_block_needs_scev_check'
1212
; CHECK: Found an early exit loop with symbolic max backedge taken count: (-1 + (1 umax (zext i10 (trunc i32 %end to i10) to i32)))<nsw>
1313
; CHECK-NEXT: LV: We can vectorize this loop!
14-
; CHECK-NEXT: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exit is not yet supported.
14+
; CHECK-NOT: LV: Not vectorizing:
1515
entry:
1616
%p1 = alloca [1024 x i32]
1717
%p2 = alloca [1024 x i32]
@@ -49,7 +49,7 @@ define i64 @same_exit_block_pre_inc_use1() {
4949
; CHECK-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1'
5050
; CHECK: LV: Found an early exit loop with symbolic max backedge taken count: 63
5151
; CHECK-NEXT: LV: We can vectorize this loop!
52-
; CHECK-NEXT: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exit is not yet supported.
52+
; CHECK-NOT: LV: Not vectorizing
5353
entry:
5454
%p1 = alloca [1024 x i8]
5555
%p2 = alloca [1024 x i8]
@@ -141,7 +141,7 @@ define i64 @loop_contains_load_after_early_exit(ptr dereferenceable(1024) align(
141141
; CHECK-LABEL: LV: Checking a loop in 'loop_contains_load_after_early_exit'
142142
; CHECK: LV: Found an early exit loop with symbolic max backedge taken count: 63
143143
; CHECK-NEXT: LV: We can vectorize this loop!
144-
; CHECK-NEXT: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exit is not yet supported.
144+
; CHECK: LV: Not vectorizing: Some exit values in loop with uncountable exit not supported yet.
145145
entry:
146146
%p1 = alloca [1024 x i8]
147147
call void @init_mem(ptr %p1, i64 1024)

0 commit comments

Comments
 (0)