diff options
author | James Molloy <james.molloy@arm.com> | 2016-08-31 13:32:28 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2016-08-31 13:32:28 +0000 |
commit | 3c1137c639c37b9e07dd58af10e01486d07bf755 (patch) | |
tree | 0e3e7a832a974636e6f92f7c7d0fe169767eb702 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 655e5a41e1f417f7e151b3b5ee71ff4968312f19 (diff) | |
download | bcm5719-llvm-3c1137c639c37b9e07dd58af10e01486d07bf755.tar.gz bcm5719-llvm-3c1137c639c37b9e07dd58af10e01486d07bf755.zip |
Revert "[SimplifyCFG] Improve FoldValueComparisonIntoPredecessors to handle more cases"
This reverts commit r280218. This *also* causes buildbot errors. Sigh. Not a successful day all around!
llvm-svn: 280239
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 9db371097e4..dc36a6e1f0b 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -174,8 +174,7 @@ public: /// Return true if it is safe to merge these two /// terminator instructions together. -static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2, - std::vector<BasicBlock*> *FailBlocks = nullptr) { +static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2) { if (SI1 == SI2) return false; // Can't merge with self! @@ -184,22 +183,18 @@ static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2, // conflicting incoming values from the two switch blocks. BasicBlock *SI1BB = SI1->getParent(); BasicBlock *SI2BB = SI2->getParent(); - SmallPtrSet<BasicBlock *, 16> SI1Succs(succ_begin(SI1BB), succ_end(SI1BB)); - bool Fail = false; + for (BasicBlock *Succ : successors(SI2BB)) if (SI1Succs.count(Succ)) for (BasicBlock::iterator BBI = Succ->begin(); isa<PHINode>(BBI); ++BBI) { PHINode *PN = cast<PHINode>(BBI); if (PN->getIncomingValueForBlock(SI1BB) != - PN->getIncomingValueForBlock(SI2BB)) { - if (FailBlocks) - FailBlocks->push_back(Succ); - Fail = true; - } + PN->getIncomingValueForBlock(SI2BB)) + return false; } - return !Fail; + return true; } /// Return true if it is safe and profitable to merge these two terminator @@ -959,16 +954,7 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(TerminatorInst *TI, TerminatorInst *PTI = Pred->getTerminator(); Value *PCV = isValueEqualityComparison(PTI); // PredCondVal - if (PCV == CV && TI != PTI) { - std::vector<BasicBlock*> FailBlocks; - if (!SafeToMergeTerminators(TI, PTI, &FailBlocks)) { - for (auto *Succ : FailBlocks) { - std::vector<BasicBlock*> Blocks = { TI->getParent() }; - if (!SplitBlockPredecessors(Succ, Blocks, ".fold.split")) - return false; - } - } - + if (PCV == CV && SafeToMergeTerminators(TI, PTI)) { // Figure out which 'cases' to copy from SI to PSI. std::vector<ValueEqualityComparisonCase> BBCases; BasicBlock *BBDefault = GetValueEqualityComparisonCases(TI, BBCases); |