Skip to content

Commit e862e78

Browse files
committed
[NFC] Use assert instead of checking the guaranteed condition
From preconditions it is known that either A dominates B or B dominates A. If A does not dominate B, we do not really need to check it. Assert should be enough. Should save some compile time.
1 parent d266fd9 commit e862e78

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,15 +2402,18 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, SCEVExpander &Rewriter) {
24022402
// Visit our exit blocks in order of dominance. We know from the fact that
24032403
// all exits must dominate the latch, so there is a total dominance order
24042404
// between them.
2405-
llvm::sort(ExitingBlocks,
2406-
[&](BasicBlock *A, BasicBlock *B) {
2405+
llvm::sort(ExitingBlocks, [&](BasicBlock *A, BasicBlock *B) {
24072406
// std::sort sorts in ascending order, so we want the inverse of
24082407
// the normal dominance relation.
24092408
if (A == B) return false;
2410-
if (DT->properlyDominates(A, B)) return true;
2411-
if (DT->properlyDominates(B, A)) return false;
2412-
llvm_unreachable("expected total dominance order!");
2413-
});
2409+
if (DT->properlyDominates(A, B))
2410+
return true;
2411+
else {
2412+
assert(DT->properlyDominates(B, A) &&
2413+
"expected total dominance order!");
2414+
return false;
2415+
}
2416+
});
24142417
#ifdef ASSERT
24152418
for (unsigned i = 1; i < ExitingBlocks.size(); i++) {
24162419
assert(DT->dominates(ExitingBlocks[i-1], ExitingBlocks[i]));

0 commit comments

Comments
 (0)