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
This commit is contained in:
Zhou Sheng
2007-01-11 12:24:14 +00:00
parent 057809ac1c
commit 6b6b6ef167
43 changed files with 1974 additions and 1868 deletions

View File

@ -416,13 +416,14 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
} else {
LatticeVal &BCValue = getValueState(BI->getCondition());
if (BCValue.isOverdefined() ||
(BCValue.isConstant() && !isa<ConstantBool>(BCValue.getConstant()))) {
(BCValue.isConstant() &&
BCValue.getConstant()->getType() != Type::BoolTy)) {
// Overdefined condition variables, and branches on unfoldable constant
// conditions, mean the branch could go either way.
Succs[0] = Succs[1] = true;
} else if (BCValue.isConstant()) {
// Constant condition variables mean the branch can only go a single way
Succs[BCValue.getConstant() == ConstantBool::getFalse()] = true;
Succs[BCValue.getConstant() == ConstantInt::getFalse()] = true;
}
}
} else if (isa<InvokeInst>(&TI)) {
@ -476,11 +477,11 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
return true;
} else if (BCValue.isConstant()) {
// Not branching on an evaluatable constant?
if (!isa<ConstantBool>(BCValue.getConstant())) return true;
if (BCValue.getConstant()->getType() != Type::BoolTy) return true;
// Constant condition variables mean the branch can only go a single way
return BI->getSuccessor(BCValue.getConstant() ==
ConstantBool::getFalse()) == To;
ConstantInt::getFalse()) == To;
}
return false;
}
@ -646,10 +647,11 @@ void SCCPSolver::visitSelectInst(SelectInst &I) {
LatticeVal &CondValue = getValueState(I.getCondition());
if (CondValue.isUndefined())
return;
if (CondValue.isConstant()) {
if (ConstantBool *CondCB = dyn_cast<ConstantBool>(CondValue.getConstant())){
mergeInValue(&I, getValueState(CondCB->getValue() ? I.getTrueValue()
: I.getFalseValue()));
if (CondValue.isConstant() &&
CondValue.getConstant()->getType() == Type::BoolTy) {
if (ConstantInt *CondCB = dyn_cast<ConstantInt>(CondValue.getConstant())){
mergeInValue(&I, getValueState(CondCB->getBoolValue() ? I.getTrueValue()
: I.getFalseValue()));
return;
}
}
@ -712,8 +714,8 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
return; // X and 0 = 0
}
} else {
if (ConstantIntegral *CI =
dyn_cast<ConstantIntegral>(NonOverdefVal->getConstant()))
if (ConstantInt *CI =
dyn_cast<ConstantInt>(NonOverdefVal->getConstant()))
if (CI->isAllOnesValue()) {
markConstant(IV, &I, NonOverdefVal->getConstant());
return; // X or -1 = -1