[llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneFunction.cpp CodeExtractor.cpp Local.cpp SimplifyCFG.cpp ValueMapper.cpp
Zhou Sheng
zhousheng00 at gmail.com
Thu Jan 11 04:25:06 PST 2007
Changes in directory llvm/lib/Transforms/Utils:
CloneFunction.cpp updated: 1.34 -> 1.35
CodeExtractor.cpp updated: 1.44 -> 1.45
Local.cpp updated: 1.63 -> 1.64
SimplifyCFG.cpp updated: 1.108 -> 1.109
ValueMapper.cpp updated: 1.27 -> 1.28
---
Log message:
For PR1043: http://llvm.org/PR1043 :
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.
---
Diffs of the changes: (+21 -15)
CloneFunction.cpp | 13 ++++++++-----
CodeExtractor.cpp | 2 +-
Local.cpp | 6 +++---
SimplifyCFG.cpp | 13 ++++++++-----
ValueMapper.cpp | 2 +-
5 files changed, 21 insertions(+), 15 deletions(-)
Index: llvm/lib/Transforms/Utils/CloneFunction.cpp
diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.34 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.35
--- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.34 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Utils/CloneFunction.cpp Thu Jan 11 06:24:14 2007
@@ -226,11 +226,14 @@
if (const BranchInst *BI = dyn_cast<BranchInst>(OldTI)) {
if (BI->isConditional()) {
// If the condition was a known constant in the callee...
- ConstantBool *Cond = dyn_cast<ConstantBool>(BI->getCondition());
- if (Cond == 0) // Or is a known constant in the caller...
- Cond = dyn_cast_or_null<ConstantBool>(ValueMap[BI->getCondition()]);
- if (Cond) { // Constant fold to uncond branch!
- BasicBlock *Dest = BI->getSuccessor(!Cond->getValue());
+ ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition());
+ // Or is a known constant in the caller...
+ if (Cond == 0)
+ Cond = dyn_cast_or_null<ConstantInt>(ValueMap[BI->getCondition()]);
+
+ // Constant fold to uncond branch!
+ if (Cond) {
+ BasicBlock *Dest = BI->getSuccessor(!Cond->getBoolValue());
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.44 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.45
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.44 Sat Dec 30 23:48:39 2006
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Thu Jan 11 06:24:14 2007
@@ -470,7 +470,7 @@
case 0:
case 1: break; // No value needed.
case 2: // Conditional branch, return a bool
- brVal = ConstantBool::get(!SuccNum);
+ brVal = ConstantInt::get(!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.63 llvm/lib/Transforms/Utils/Local.cpp:1.64
--- llvm/lib/Transforms/Utils/Local.cpp:1.63 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Jan 11 06:24:14 2007
@@ -173,11 +173,11 @@
BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0));
BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1));
- if (ConstantBool *Cond = dyn_cast<ConstantBool>(BI->getCondition())) {
+ if (ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition())) {
// Are we branching on constant?
// YES. Change to unconditional branch...
- BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
- BasicBlock *OldDest = Cond->getValue() ? Dest2 : Dest1;
+ BasicBlock *Destination = Cond->getBoolValue() ? Dest1 : Dest2;
+ BasicBlock *OldDest = Cond->getBoolValue() ? 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.108 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.109
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.108 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Thu Jan 11 06:24:14 2007
@@ -968,12 +968,14 @@
// 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 @@
// Recurse, simplifying any other constants.
return FoldCondBranchOnPHI(BI) | true;
}
+ }
return false;
}
@@ -1506,7 +1509,7 @@
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 @@
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);
}
Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.27 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.28
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.27 Fri Jul 14 17:21:13 2006
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp Thu Jan 11 06:24:14 2007
@@ -28,7 +28,7 @@
return VMSlot = const_cast<Value*>(V);
if (Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V))) {
- if (isa<ConstantIntegral>(C) || isa<ConstantFP>(C) ||
+ if (isa<ConstantInt>(C) || isa<ConstantFP>(C) ||
isa<ConstantPointerNull>(C) || isa<ConstantAggregateZero>(C) ||
isa<UndefValue>(C))
return VMSlot = C; // Primitive constants map directly
More information about the llvm-commits
mailing list