Skip to content

Commit b1d2c62

Browse files
committed
[VPlan] Unconditionally run attachRuntimeChecks (NFCI).
Instead of conditionally executing attachRuntimeChecks, directly check if the blocks to be added are still disconnected.
1 parent e5a4ea2 commit b1d2c62

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7213,11 +7213,9 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
72137213
BestVPlan, BestVF, VScale);
72147214
}
72157215

7216-
if (!VectorizingEpilogue) {
7217-
// Checks are the same for all VPlans, added to BestVPlan only for
7218-
// compactness.
7219-
attachRuntimeChecks(BestVPlan, ILV.RTChecks, HasBranchWeights);
7220-
}
7216+
// Checks are the same for all VPlans, added to BestVPlan only for
7217+
// compactness.
7218+
attachRuntimeChecks(BestVPlan, ILV.RTChecks, HasBranchWeights);
72217219

72227220
// Retrieving VectorPH now when it's easier while VPlan still has Regions.
72237221
VPBasicBlock *VectorPH = cast<VPBasicBlock>(BestVPlan.getVectorPreheader());
@@ -9248,15 +9246,15 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92489246
void LoopVectorizationPlanner::attachRuntimeChecks(
92499247
VPlan &Plan, GeneratedRTChecks &RTChecks, bool HasBranchWeights) const {
92509248
const auto &[SCEVCheckCond, SCEVCheckBlock] = RTChecks.getSCEVChecks();
9251-
if (SCEVCheckBlock) {
9249+
if (SCEVCheckBlock && SCEVCheckBlock->hasNPredecessors(0)) {
92529250
assert((!CM.OptForSize ||
92539251
CM.Hints->getForce() == LoopVectorizeHints::FK_Enabled) &&
92549252
"Cannot SCEV check stride or overflow when optimizing for size");
92559253
VPlanTransforms::attachCheckBlock(Plan, SCEVCheckCond, SCEVCheckBlock,
92569254
HasBranchWeights);
92579255
}
92589256
const auto &[MemCheckCond, MemCheckBlock] = RTChecks.getMemRuntimeChecks();
9259-
if (MemCheckBlock) {
9257+
if (MemCheckBlock && MemCheckBlock->hasNPredecessors(0)) {
92609258
// VPlan-native path does not do any analysis for runtime checks
92619259
// currently.
92629260
assert((!EnableVPlanNativePath || OrigLoop->isInnermost()) &&

0 commit comments

Comments
 (0)