diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-14 05:57:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-14 05:57:30 +0000 |
commit | 5a9d59d9185f25175e4ea0e38daca1ad088b1ec3 (patch) | |
tree | df0d5890714b677fd0b86c0778ee888108e784ea /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 72eff18ae4fd86c3178e10f72fa2663cf947a05a (diff) | |
download | bcm5719-llvm-5a9d59d9185f25175e4ea0e38daca1ad088b1ec3.tar.gz bcm5719-llvm-5a9d59d9185f25175e4ea0e38daca1ad088b1ec3.zip |
reapply my recent change that disables a piece of the switch formation
work, but fixes 400.perlbmk.
llvm-svn: 121749
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ca690e7f870..15e487c70c3 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1515,7 +1515,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI) { AddPredecessorToBlock(FalseDest, PredBlock, BB); PBI->setSuccessor(1, FalseDest); } - return SimplifyCFG(PBI->getParent()) | true; + return true; } return false; } @@ -1905,17 +1905,25 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) { BasicBlock *BB = BI->getParent(); + DEBUG(dbgs() << "CONVERTING 'icmp' CHAIN with " << Values.size() + << " cases into SWITCH. BB is:\n" << *BB); + // If there are any extra values that couldn't be folded into the switch // then we evaluate them with an explicit branch first. Split the block // right before the condbr to handle it. if (ExtraCase) { - return false; + DEBUG(dbgs() << " ** 'icmp' chain unhandled condition: " << *ExtraCase + << '\n'); BasicBlock *NewBB = BB->splitBasicBlock(BI, "switch.early.test"); // Remove the uncond branch added to the old block. TerminatorInst *OldTI = BB->getTerminator(); - BranchInst::Create(EdgeBB, NewBB, ExtraCase, OldTI); + if (TrueWhenEqual) + BranchInst::Create(EdgeBB, NewBB, ExtraCase, OldTI); + else + BranchInst::Create(NewBB, EdgeBB, ExtraCase, OldTI); + OldTI->eraseFromParent(); // If there are PHI nodes in EdgeBB, then we need to add a new entry to them @@ -1955,6 +1963,7 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) { // Erase the old branch instruction. EraseTerminatorInstAndDCECond(BI); + return true; } @@ -2410,8 +2419,7 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) { if (BI->isUnconditional()) { if (SimplifyUncondBranch(BI)) return true; } else { - if (SimplifyCondBranch(BI)) - return true; + if (SimplifyCondBranch(BI)) return true; } } else if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) { if (SimplifyReturn(RI)) return true; |