Skip to content

Commit de60516

Browse files
committed
!fixup after merge of current main
1 parent a13fe54 commit de60516

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9058,7 +9058,7 @@ addUsersInExitBlocks(VPlan &Plan,
90589058
// Introduce extract for exiting values and update the VPIRInstructions
90599059
// modeling the corresponding LCSSA phis.
90609060
for (VPIRInstruction *ExitIRI : ExitUsersToFix) {
9061-
for (VPValue *Op : ExitIRI->operands()) {
9061+
for (const auto &[Idx, Op] : enumerate(ExitIRI->operands())) {
90629062
// Pass live-in values used by exit phis directly through to their users
90639063
// in the exit block.
90649064
if (Op->isLiveIn())
@@ -9073,7 +9073,7 @@ addUsersInExitBlocks(VPlan &Plan,
90739073
VPValue *Ext = B.createNaryOp(VPInstruction::ExtractFromEnd,
90749074
{Op, Plan.getOrAddLiveIn(ConstantInt::get(
90759075
IntegerType::get(Ctx, 32), 1))});
9076-
ExitIRI->setOperand(0, Ext);
9076+
ExitIRI->setOperand(Idx, Ext);
90779077
}
90789078
}
90799079
return true;
@@ -10236,36 +10236,11 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1023610236
return false;
1023710237
}
1023810238

10239-
if (LVL.hasUncountableEarlyExit()) {
10240-
if (!EnableEarlyExitVectorization) {
10241-
reportVectorizationFailure("Auto-vectorization of loops with uncountable "
10242-
"early exit is not enabled",
10243-
"UncountableEarlyExitLoopsDisabled", ORE, L);
10244-
return false;
10245-
}
10246-
10247-
// In addUsersInExitBlocks we already bail out if there is an outside use
10248-
// of a loop-defined variable, but it ignores induction variables which are
10249-
// handled by InnerLoopVectorizer::fixupIVUsers. We need to bail out if we
10250-
// encounter induction variables too otherwise fixupIVUsers will crash.
10251-
BasicBlock *LoopLatch = L->getLoopLatch();
10252-
for (const auto &Induction : LVL.getInductionVars()) {
10253-
PHINode *Ind = Induction.first;
10254-
Instruction *IndUpdate =
10255-
cast<Instruction>(Ind->getIncomingValueForBlock(LoopLatch));
10256-
for (Instruction *I : {cast<Instruction>(Ind), IndUpdate}) {
10257-
for (User *U : I->users()) {
10258-
Instruction *UI = cast<Instruction>(U);
10259-
if (!L->contains(UI)) {
10260-
reportVectorizationFailure(
10261-
"Auto-vectorization of loops with uncountable early exits and "
10262-
"outside uses of induction variables unsupported",
10263-
"UncountableEarlyExitLoopIndLiveOutsUnsupported", ORE, L);
10264-
return false;
10265-
}
10266-
}
10267-
}
10268-
}
10239+
if (LVL.hasUncountableEarlyExit() && !EnableEarlyExitVectorization) {
10240+
reportVectorizationFailure("Auto-vectorization of loops with uncountable "
10241+
"early exit is not enabled",
10242+
"UncountableEarlyExitLoopsDisabled", ORE, L);
10243+
return false;
1026910244
}
1027010245

1027110246
// Entrance to the VPlan-native vectorization path. Outer loops are processed

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 exits and outside uses of induction variables unsupported
52+
; CHECK: LV: Not vectorizing: Some exit values in loop with uncountable exit not supported yet.
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 exits and outside uses of induction variables unsupported
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)