Skip to content

Commit 1f6e155

Browse files
committed
[LV] Weaken a unnecessarily strong assert [NFC]
Account for the fact that (in the future) the latch might be a switch not a branch. The existing code is correct, minus the assert.
1 parent ec6b71d commit 1f6e155

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,14 +3409,7 @@ BasicBlock *InnerLoopVectorizer::completeLoopSkeleton(Loop *L,
34093409
Value *Count = getOrCreateTripCount(L);
34103410
Value *VectorTripCount = getOrCreateVectorTripCount(L);
34113411

3412-
// We need the OrigLoop (scalar loop part) latch terminator to help
3413-
// produce correct debug info for the middle block BB instructions.
3414-
// The legality check stage guarantees that the loop will have a single
3415-
// latch.
3416-
assert(isa<BranchInst>(OrigLoop->getLoopLatch()->getTerminator()) &&
3417-
"Scalar loop latch terminator isn't a branch");
3418-
BranchInst *ScalarLatchBr =
3419-
cast<BranchInst>(OrigLoop->getLoopLatch()->getTerminator());
3412+
auto *ScalarLatchTerm = OrigLoop->getLoopLatch()->getTerminator();
34203413

34213414
// Add a check in the middle block to see if we have completed
34223415
// all of the iterations in the first vector loop.
@@ -3428,16 +3421,16 @@ BasicBlock *InnerLoopVectorizer::completeLoopSkeleton(Loop *L,
34283421
VectorTripCount, "cmp.n",
34293422
LoopMiddleBlock->getTerminator());
34303423

3431-
// Here we use the same DebugLoc as the scalar loop latch branch instead
3424+
// Here we use the same DebugLoc as the scalar loop latch terminator instead
34323425
// of the corresponding compare because they may have ended up with
34333426
// different line numbers and we want to avoid awkward line stepping while
34343427
// debugging. Eg. if the compare has got a line number inside the loop.
3435-
cast<Instruction>(CmpN)->setDebugLoc(ScalarLatchBr->getDebugLoc());
3428+
cast<Instruction>(CmpN)->setDebugLoc(ScalarLatchTerm->getDebugLoc());
34363429
}
34373430

34383431
BranchInst *BrInst =
34393432
BranchInst::Create(LoopExitBlock, LoopScalarPreHeader, CmpN);
3440-
BrInst->setDebugLoc(ScalarLatchBr->getDebugLoc());
3433+
BrInst->setDebugLoc(ScalarLatchTerm->getDebugLoc());
34413434
ReplaceInstWithInst(LoopMiddleBlock->getTerminator(), BrInst);
34423435

34433436
// Get ready to start creating new instructions into the vectorized body.

0 commit comments

Comments
 (0)