[llvm] e862e78 - [NFC] Use assert instead of checking the guaranteed condition
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 21:45:09 PDT 2020
Author: Max Kazantsev
Date: 2020-09-29T11:38:45+07:00
New Revision: e862e78b63f918c000ce65f9c475730e673a4966
URL: https://github.com/llvm/llvm-project/commit/e862e78b63f918c000ce65f9c475730e673a4966
DIFF: https://github.com/llvm/llvm-project/commit/e862e78b63f918c000ce65f9c475730e673a4966.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index d425d294e757..e8b38dcdc885 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2402,15 +2402,18 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, SCEVExpander &Rewriter) {
// Visit our exit blocks in order of dominance. We know from the fact that
// all exits must dominate the latch, so there is a total dominance order
// between them.
- llvm::sort(ExitingBlocks,
- [&](BasicBlock *A, BasicBlock *B) {
+ llvm::sort(ExitingBlocks, [&](BasicBlock *A, BasicBlock *B) {
// std::sort sorts in ascending order, so we want the inverse of
// the normal dominance relation.
if (A == B) return false;
- if (DT->properlyDominates(A, B)) return true;
- if (DT->properlyDominates(B, A)) return false;
- llvm_unreachable("expected total dominance order!");
- });
+ if (DT->properlyDominates(A, B))
+ return true;
+ else {
+ assert(DT->properlyDominates(B, A) &&
+ "expected total dominance order!");
+ return false;
+ }
+ });
#ifdef ASSERT
for (unsigned i = 1; i < ExitingBlocks.size(); i++) {
assert(DT->dominates(ExitingBlocks[i-1], ExitingBlocks[i]));
More information about the llvm-commits
mailing list