Skip to content

Commit 6918d2c

Browse files
committed
Address review comments
1 parent c4746a9 commit 6918d2c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,12 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
18091809
for (PHINode *PN : Cleanup)
18101810
RecursivelyDeleteDeadPHINode(PN);
18111811

1812+
// LoopDeletion only delete invariant loops with known trip-count. We can
1813+
// update the condition so it will reliablely delete the invariant loop
1814+
assert(LoopTerm->getNumSuccessors() == 2 &&
1815+
(LoopTerm->getSuccessor(0) == LoopBody ||
1816+
LoopTerm->getSuccessor(1) == LoopBody) &&
1817+
"loop body must have a successor that is it self");
18121818
ConstantInt *NewLoopCond = LoopTerm->getSuccessor(0) == LoopBody
18131819
? Builder.getFalse()
18141820
: Builder.getTrue();

0 commit comments

Comments
 (0)