summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnswitch.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
index bc97cacf2b8..b1258675892 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -910,6 +910,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
BranchInst *OldBranch,
TerminatorInst *TI) {
assert(OldBranch->isUnconditional() && "Preheader is not split correctly");
+ assert(TrueDest != FalseDest && "Branch targets should be different");
// Insert a conditional branch on LIC to the two preheaders. The original
// code is the true version and the new code is the false version.
Value *BranchVal = LIC;
@@ -942,9 +943,9 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
if (DT) {
// First, add both successors.
SmallVector<DominatorTree::UpdateType, 3> Updates;
- if (TrueDest != OldBranchParent)
+ if (TrueDest != OldBranchSucc)
Updates.push_back({DominatorTree::Insert, OldBranchParent, TrueDest});
- if (FalseDest != OldBranchParent)
+ if (FalseDest != OldBranchSucc)
Updates.push_back({DominatorTree::Insert, OldBranchParent, FalseDest});
// If both of the new successors are different from the old one, inform the
// DT that the edge was deleted.
OpenPOWER on IntegriCloud