Skip to content

Commit 0ebac76

Browse files
committed
[LV] Remove unneeded Loop argument from completeLoopSkeleton. (NFCI)
completeLoopSkeleton only uses its loop argument only to get the pre-header, but the pre-header is already known (we created/cached it earlier). Remove the unneeded loop argument.
1 parent 73a15ad commit 0ebac76

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,8 @@ class InnerLoopVectorizer {
646646

647647
/// Complete the loop skeleton by adding debug MDs, creating appropriate
648648
/// conditional branches in the middle block, preparing the builder and
649-
/// running the verifier. Take in the vector loop \p L as argument, and return
650-
/// the preheader of the completed vector loop.
651-
BasicBlock *completeLoopSkeleton(Loop *L, MDNode *OrigLoopID);
649+
/// running the verifier. Return the preheader of the completed vector loop.
650+
BasicBlock *completeLoopSkeleton(MDNode *OrigLoopID);
652651

653652
/// Add additional metadata to \p To that was not present on \p Orig.
654653
///
@@ -3234,13 +3233,10 @@ void InnerLoopVectorizer::createInductionResumeValues(
32343233
}
32353234
}
32363235

3237-
BasicBlock *InnerLoopVectorizer::completeLoopSkeleton(Loop *L,
3238-
MDNode *OrigLoopID) {
3239-
assert(L && "Expected valid loop.");
3240-
3236+
BasicBlock *InnerLoopVectorizer::completeLoopSkeleton(MDNode *OrigLoopID) {
32413237
// The trip counts should be cached by now.
3242-
Value *Count = getOrCreateTripCount(L->getLoopPreheader());
3243-
Value *VectorTripCount = getOrCreateVectorTripCount(L->getLoopPreheader());
3238+
Value *Count = getOrCreateTripCount(LoopVectorPreHeader);
3239+
Value *VectorTripCount = getOrCreateVectorTripCount(LoopVectorPreHeader);
32443240

32453241
auto *ScalarLatchTerm = OrigLoop->getLoopLatch()->getTerminator();
32463242

@@ -3265,10 +3261,6 @@ BasicBlock *InnerLoopVectorizer::completeLoopSkeleton(Loop *L,
32653261
cast<BranchInst>(LoopMiddleBlock->getTerminator())->setCondition(CmpN);
32663262
}
32673263

3268-
// Get ready to start creating new instructions into the vectorized body.
3269-
assert(LoopVectorPreHeader == L->getLoopPreheader() &&
3270-
"Inconsistent vector loop preheader");
3271-
32723264
#ifdef EXPENSIVE_CHECKS
32733265
assert(DT->verify(DominatorTree::VerificationLevel::Fast));
32743266
LI->verify(*DT);
@@ -3348,7 +3340,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton() {
33483340
// Emit phis for the new starting index of the scalar loop.
33493341
createInductionResumeValues(Lp);
33503342

3351-
return {completeLoopSkeleton(Lp, OrigLoopID), nullptr};
3343+
return {completeLoopSkeleton(OrigLoopID), nullptr};
33523344
}
33533345

33543346
// Fix up external users of the induction variable. At this point, we are
@@ -7897,7 +7889,7 @@ EpilogueVectorizerMainLoop::createEpilogueVectorizedLoopSkeleton() {
78977889
// because the vplan in the second pass still contains the inductions from the
78987890
// original loop.
78997891

7900-
return {completeLoopSkeleton(Lp, OrigLoopID), nullptr};
7892+
return {completeLoopSkeleton(OrigLoopID), nullptr};
79017893
}
79027894

79037895
void EpilogueVectorizerMainLoop::printDebugTracesAtStart() {
@@ -8076,7 +8068,7 @@ EpilogueVectorizerEpilogueLoop::createEpilogueVectorizedLoopSkeleton() {
80768068
createInductionResumeValues(Lp, {VecEpilogueIterationCountCheck,
80778069
EPI.VectorTripCount} /* AdditionalBypass */);
80788070

8079-
return {completeLoopSkeleton(Lp, OrigLoopID), EPResumeVal};
8071+
return {completeLoopSkeleton(OrigLoopID), EPResumeVal};
80808072
}
80818073

80828074
BasicBlock *

0 commit comments

Comments
 (0)