diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-12 04:24:46 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-12 04:24:46 +0000 |
commit | cddc9dfe975c3152a2db955b24cb6b4ee457e571 (patch) | |
tree | a06773a4c05b5949c043c0246fcb64b88f073653 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | e4c7fcd1bd0e85b1dc83bed2c8a293cbd1514317 (diff) | |
download | bcm5719-llvm-cddc9dfe975c3152a2db955b24cb6b4ee457e571.tar.gz bcm5719-llvm-cddc9dfe975c3152a2db955b24cb6b4ee457e571.zip |
Implement review feedback for the ConstantBool->ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.
llvm-svn: 33110
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 964b47c4efb..25bc16866f3 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -975,7 +975,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { // Okay, we now know that all edges from PredBB should be revectored to // branch to RealDest. BasicBlock *PredBB = PN->getIncomingBlock(i); - BasicBlock *RealDest = BI->getSuccessor(!CB->getBoolValue()); + BasicBlock *RealDest = BI->getSuccessor(!CB->getZExtValue()); if (RealDest == BB) continue; // Skip self loops. @@ -1500,8 +1500,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { if (PBI != BI && PBI->isConditional()) { // If this block ends with a branch instruction, and if there is a - // predecessor that ends on a branch of the same condition, make this - // conditional branch redundant. + // predecessor that ends on a branch of the same condition, make + // this conditional branch redundant. if (PBI->getCondition() == BI->getCondition() && PBI->getSuccessor(0) != PBI->getSuccessor(1)) { // Okay, the outcome of this conditional branch is statically @@ -1509,23 +1509,24 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { if (BB->getSinglePredecessor()) { // Turn this into a branch on constant. bool CondIsTrue = PBI->getSuccessor(0) == BB; - BI->setCondition(ConstantInt::get(CondIsTrue)); + BI->setCondition(ConstantInt::get(Type::Int1Ty, CondIsTrue)); return SimplifyCFG(BB); // Nuke the branch on constant. } - // Otherwise, if there are multiple predecessors, insert a PHI that - // merges in the constant and simplify the block result. + // Otherwise, if there are multiple predecessors, insert a PHI + // that merges in the constant and simplify the block result. if (BlockIsSimpleEnoughToThreadThrough(BB)) { PHINode *NewPN = new PHINode(Type::Int1Ty, - BI->getCondition()->getName()+".pr", - BB->begin()); + BI->getCondition()->getName()+".pr", + BB->begin()); for (PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) if ((PBI = dyn_cast<BranchInst>((*PI)->getTerminator())) && PBI != BI && PBI->isConditional() && PBI->getCondition() == BI->getCondition() && PBI->getSuccessor(0) != PBI->getSuccessor(1)) { bool CondIsTrue = PBI->getSuccessor(0) == BB; - NewPN->addIncoming(ConstantInt::get(CondIsTrue), *PI); + NewPN->addIncoming(ConstantInt::get(Type::Int1Ty, + CondIsTrue), *PI); } else { NewPN->addIncoming(BI->getCondition(), *PI); } |