summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
index 5ca412f1a20..f2d592f04c3 100644
--- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
@@ -249,6 +249,7 @@ private:
SmallPtrSet<BasicBlock *, 2> DeadSuccessors;
// Remove all BB's successors except for the live one.
+ unsigned TheOnlySuccDuplicates = 0;
for (auto *Succ : successors(BB))
if (Succ != TheOnlySucc) {
DeadSuccessors.insert(Succ);
@@ -256,7 +257,16 @@ private:
// the one-input Phi because it is a LCSSA Phi.
bool PreserveLCSSAPhi = !L.contains(Succ);
Succ->removePredecessor(BB, PreserveLCSSAPhi);
- }
+ } else
+ ++TheOnlySuccDuplicates;
+
+ assert(TheOnlySuccDuplicates > 0 && "Should be!");
+ // If TheOnlySucc was BB's successor more than once, after transform it
+ // will be its successor only once. Remove redundant inputs from
+ // TheOnlySucc's Phis.
+ bool PreserveLCSSAPhi = !L.contains(TheOnlySucc);
+ for (unsigned Dup = 1; Dup < TheOnlySuccDuplicates; ++Dup)
+ TheOnlySucc->removePredecessor(BB, PreserveLCSSAPhi);
IRBuilder<> Builder(BB->getContext());
Instruction *Term = BB->getTerminator();
OpenPOWER on IntegriCloud