Skip to content

Commit 144c6d4

Browse files
committed
Address review comment
1 parent d4f3c25 commit 144c6d4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10213,15 +10213,19 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1021310213
// of a loop-defined variable, but it ignores induction variables which are
1021410214
// handled by InnerLoopVectorizer::fixupIVUsers. We need to bail out if we
1021510215
// encounter induction variables too otherwise fixupIVUsers will crash.
10216-
for (BasicBlock *BB : L->blocks()) {
10217-
for (Instruction &I : *BB) {
10218-
for (User *U : I.users()) {
10216+
BasicBlock *LoopLatch = L->getLoopLatch();
10217+
for (const auto &Induction : LVL.getInductionVars()) {
10218+
PHINode *Ind = Induction.first;
10219+
Instruction *IndUpdate =
10220+
cast<Instruction>(Ind->getIncomingValueForBlock(LoopLatch));
10221+
for (Instruction *I : {cast<Instruction>(Ind), IndUpdate}) {
10222+
for (User *U : I->users()) {
1021910223
Instruction *UI = cast<Instruction>(U);
1022010224
if (!L->contains(UI)) {
1022110225
reportVectorizationFailure(
10222-
"Auto-vectorization of loops with uncountable "
10223-
"early exit and live-outs is not supported",
10224-
"UncountableEarlyExitLoopLiveOutsUnsupported", ORE, L);
10226+
"Auto-vectorization of loops with uncountable early exits and "
10227+
"outside uses of induction variables unsupported",
10228+
"UncountableEarlyExitLoopIndLiveOutsUnsupported", ORE, L);
1022510229
return false;
1022610230
}
1022710231
}

llvm/test/Transforms/LoopVectorize/early_exit_legality.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 and live-outs is not supported.
52+
; CHECK-NEXT: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exits and outside uses of induction variables unsupported
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: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exit and live-outs is not supported.
144+
; CHECK: LV: Not vectorizing: Auto-vectorization of loops with uncountable early exits and outside uses of induction variables unsupported
145145
entry:
146146
%p1 = alloca [1024 x i8]
147147
call void @init_mem(ptr %p1, i64 1024)

0 commit comments

Comments
 (0)