[llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneFunction.cpp CodeExtractor.cpp Local.cpp SimplifyCFG.cpp
Reid Spencer
reid at x10sys.com
Thu Jan 11 20:25:29 PST 2007
Changes in directory llvm/lib/Transforms/Utils:
CloneFunction.cpp updated: 1.35 -> 1.36
CodeExtractor.cpp updated: 1.46 -> 1.47
Local.cpp updated: 1.64 -> 1.65
SimplifyCFG.cpp updated: 1.110 -> 1.111
---
Log message:
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.
---
Diffs of the changes: (+14 -13)
CloneFunction.cpp | 2 +-
CodeExtractor.cpp | 2 +-
Local.cpp | 4 ++--
SimplifyCFG.cpp | 19 ++++++++++---------
4 files changed, 14 insertions(+), 13 deletions(-)
Index: llvm/lib/Transforms/Utils/CloneFunction.cpp
diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.35 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.36
--- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.35 Thu Jan 11 06:24:14 2007
+++ llvm/lib/Transforms/Utils/CloneFunction.cpp Thu Jan 11 22:24:46 2007
@@ -233,7 +233,7 @@
// Constant fold to uncond branch!
if (Cond) {
- BasicBlock *Dest = BI->getSuccessor(!Cond->getBoolValue());
+ BasicBlock *Dest = BI->getSuccessor(!Cond->getZExtValue());
ValueMap[OldTI] = new BranchInst(Dest, NewBB);
CloneBlock(Dest);
TerminatorDone = true;
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.46 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.47
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.46 Thu Jan 11 12:21:29 2007
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Thu Jan 11 22:24:46 2007
@@ -470,7 +470,7 @@
case 0:
case 1: break; // No value needed.
case 2: // Conditional branch, return a bool
- brVal = ConstantInt::get(!SuccNum);
+ brVal = ConstantInt::get(Type::Int1Ty, !SuccNum);
break;
default:
brVal = ConstantInt::get(Type::Int16Ty, SuccNum);
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.64 llvm/lib/Transforms/Utils/Local.cpp:1.65
--- llvm/lib/Transforms/Utils/Local.cpp:1.64 Thu Jan 11 06:24:14 2007
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Jan 11 22:24:46 2007
@@ -176,8 +176,8 @@
if (ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition())) {
// Are we branching on constant?
// YES. Change to unconditional branch...
- BasicBlock *Destination = Cond->getBoolValue() ? Dest1 : Dest2;
- BasicBlock *OldDest = Cond->getBoolValue() ? Dest2 : Dest1;
+ BasicBlock *Destination = Cond->getZExtValue() ? Dest1 : Dest2;
+ BasicBlock *OldDest = Cond->getZExtValue() ? Dest2 : Dest1;
//cerr << "Function: " << T->getParent()->getParent()
// << "\nRemoving branch from " << T->getParent()
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.110 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.111
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.110 Thu Jan 11 12:21:29 2007
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Thu Jan 11 22:24:46 2007
@@ -975,7 +975,7 @@
// 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 @@
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 @@
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);
}
More information about the llvm-commits
mailing list