aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-05-25 18:17:13 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-05-25 18:17:13 +0000
commit237d10db8c3d8677b17bb447e3504674b2d31393 (patch)
treeb19374bb1076dae0db5e0e488de4cc9dbebd9de0 /lib/Transforms/Scalar/LoopUnswitch.cpp
parent4c62f765a308543577d7e0094020d8d9362a8bcb (diff)
Simplify r132022 based on Cameron's feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index a33e795643..01a99af143 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -919,18 +919,11 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
BasicBlock *Switch = SI->getParent();
BasicBlock *SISucc = SI->getSuccessor(DeadCase);
BasicBlock *Latch = L->getLoopLatch();
- // If the DeadCase successor dominates all of the predecessors of the
- // loop latch, then the transformation isn't safe since it will delete
- // the predecessor edges to the latch.
- if (Latch) {
- bool DominateAll = true;
- for (pred_iterator PI = pred_begin(Latch), PE = pred_end(Latch);
- DominateAll && PI != PE; ++PI)
- if (!DT->dominates(SISucc, *PI))
- DominateAll = false;
- if (DominateAll)
- continue;
- }
+ // If the DeadCase successor dominates the loop latch, then the
+ // transformation isn't safe since it will delete the sole predecessor edge
+ // to the latch.
+ if (Latch && DT->dominates(SISucc, Latch))
+ continue;
// FIXME: This is a hack. We need to keep the successor around
// and hooked up so as to preserve the loop structure, because