Skip to content

Commit e806940

Browse files
author
git apple-llvm automerger
committed
Merge commit 'a485e0eae01b' from llvm.org/main into next
2 parents 1d0d17c + a485e0e commit e806940

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7530,9 +7530,6 @@ BasicBlock *EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton() {
75307530
EPI.MainLoopIterationCountCheck =
75317531
emitIterationCountCheck(LoopScalarPreHeader, false);
75327532

7533-
// Generate the induction variable.
7534-
EPI.VectorTripCount = getOrCreateVectorTripCount(LoopVectorPreHeader);
7535-
75367533
replaceVPBBWithIRVPBB(Plan.getScalarPreheader(), LoopScalarPreHeader);
75377534
return LoopVectorPreHeader;
75387535
}
@@ -9808,7 +9805,7 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
98089805
static void
98099806
preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98109807
const SCEV2ValueTy &ExpandedSCEVs,
9811-
const EpilogueLoopVectorizationInfo &EPI) {
9808+
EpilogueLoopVectorizationInfo &EPI) {
98129809
VPRegionBlock *VectorLoop = Plan.getVectorLoopRegion();
98139810
VPBasicBlock *Header = VectorLoop->getEntryBasicBlock();
98149811
Header->setName("vec.epilog.vector.body");
@@ -9826,30 +9823,13 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
98269823
// loop.
98279824
using namespace llvm::PatternMatch;
98289825
PHINode *EPResumeVal = &*L->getLoopPreheader()->phis().begin();
9829-
assert(EPResumeVal->getType() == IV->getScalarType() &&
9830-
match(EPResumeVal->getIncomingValueForBlock(
9831-
EPI.MainLoopIterationCountCheck),
9832-
m_SpecificInt(0)) &&
9833-
EPResumeVal ==
9834-
find_singleton<PHINode>(
9835-
L->getLoopPreheader()->phis(),
9836-
[&EPI, IV](PHINode &P, bool) -> PHINode * {
9837-
if (P.getType() == IV->getScalarType() &&
9838-
match(P.getIncomingValueForBlock(
9839-
EPI.MainLoopIterationCountCheck),
9840-
m_SpecificInt(0)) &&
9841-
any_of(P.incoming_values(),
9842-
[&EPI](Value *Inc) {
9843-
return Inc == EPI.VectorTripCount;
9844-
}) &&
9845-
all_of(P.incoming_values(), [&EPI](Value *Inc) {
9846-
return Inc == EPI.VectorTripCount ||
9847-
match(Inc, m_SpecificInt(0));
9848-
}))
9849-
return &P;
9850-
return nullptr;
9851-
}) &&
9852-
"Epilogue resume phis do not match!");
9826+
for (Value *Inc : EPResumeVal->incoming_values()) {
9827+
if (match(Inc, m_SpecificInt(0)))
9828+
continue;
9829+
assert(!EPI.VectorTripCount &&
9830+
"Must only have a single non-zero incoming value");
9831+
EPI.VectorTripCount = Inc;
9832+
}
98539833
VPValue *VPV = Plan.getOrAddLiveIn(EPResumeVal);
98549834
assert(all_of(IV->users(),
98559835
[](const VPUser *U) {

0 commit comments

Comments
 (0)