diff options
author | Zhou Sheng <zhousheng00@gmail.com> | 2007-01-11 12:24:14 +0000 |
---|---|---|
committer | Zhou Sheng <zhousheng00@gmail.com> | 2007-01-11 12:24:14 +0000 |
commit | 6b6b6ef1677fa71b1072c2911b4c1f9524a558c9 (patch) | |
tree | 480ecf010ac5facd1bc29ab57441253691bb42d6 /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 057809ac1c78c3456e8f1481330fa2bcd2b85029 (diff) |
For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index b44ab09362..0304aa3ff5 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -968,12 +968,14 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { // Okay, this is a simple enough basic block. See if any phi values are // constants. - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (ConstantBool *CB = dyn_cast<ConstantBool>(PN->getIncomingValue(i))) { + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + ConstantInt *CB; + if ((CB = dyn_cast<ConstantInt>(PN->getIncomingValue(i))) && + CB->getType() == Type::BoolTy) { // 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->getValue()); + BasicBlock *RealDest = BI->getSuccessor(!CB->getBoolValue()); if (RealDest == BB) continue; // Skip self loops. @@ -1037,6 +1039,7 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { // Recurse, simplifying any other constants. return FoldCondBranchOnPHI(BI) | true; } + } return false; } @@ -1506,7 +1509,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { if (BB->getSinglePredecessor()) { // Turn this into a branch on constant. bool CondIsTrue = PBI->getSuccessor(0) == BB; - BI->setCondition(ConstantBool::get(CondIsTrue)); + BI->setCondition(ConstantInt::get(CondIsTrue)); return SimplifyCFG(BB); // Nuke the branch on constant. } @@ -1522,7 +1525,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { PBI->getCondition() == BI->getCondition() && PBI->getSuccessor(0) != PBI->getSuccessor(1)) { bool CondIsTrue = PBI->getSuccessor(0) == BB; - NewPN->addIncoming(ConstantBool::get(CondIsTrue), *PI); + NewPN->addIncoming(ConstantInt::get(CondIsTrue), *PI); } else { NewPN->addIncoming(BI->getCondition(), *PI); } |