[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp InstructionCombining.cpp LoopUnswitch.cpp PredicateSimplifier.cpp SCCP.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 28 16:35:38 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
CorrelatedExprs.cpp updated: 1.34 -> 1.35
InstructionCombining.cpp updated: 1.515 -> 1.516
LoopUnswitch.cpp updated: 1.47 -> 1.48
PredicateSimplifier.cpp updated: 1.15 -> 1.16
SCCP.cpp updated: 1.131 -> 1.132
---
Log message:
Eliminate ConstantBool::True and ConstantBool::False. Instead, provide
ConstantBool::getTrue() and ConstantBool::getFalse().
---
Diffs of the changes: (+108 -115)
CorrelatedExprs.cpp | 7 +--
InstructionCombining.cpp | 109 ++++++++++++++++++++++++-----------------------
LoopUnswitch.cpp | 19 ++++----
PredicateSimplifier.cpp | 73 ++++++++++++++-----------------
SCCP.cpp | 15 ++----
5 files changed, 108 insertions(+), 115 deletions(-)
Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.34 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.35
--- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.34 Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Thu Sep 28 18:35:21 2006
@@ -788,12 +788,12 @@
// Propagate information into the true block...
//
- PropagateEquality(BI->getCondition(), ConstantBool::True,
+ PropagateEquality(BI->getCondition(), ConstantBool::getTrue(),
getRegionInfo(BI->getSuccessor(0)));
// Propagate information into the false block...
//
- PropagateEquality(BI->getCondition(), ConstantBool::False,
+ PropagateEquality(BI->getCondition(), ConstantBool::getFalse(),
getRegionInfo(BI->getSuccessor(1)));
}
@@ -971,8 +971,7 @@
// See if we can figure out a result for this instruction...
Relation::KnownResult Result = getSetCCResult(SCI, RI);
if (Result != Relation::Unknown) {
- PropagateEquality(SCI, Result ? ConstantBool::True : ConstantBool::False,
- RI);
+ PropagateEquality(SCI, ConstantBool::get(Result != 0), RI);
}
}
}
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.515 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.516
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.515 Wed Sep 20 10:37:57 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Sep 28 18:35:21 2006
@@ -1989,7 +1989,7 @@
if (ST->isNullValue()) {
Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
if (CondI && CondI->getParent() == I.getParent())
- UpdateValueUsesWith(CondI, ConstantBool::False);
+ UpdateValueUsesWith(CondI, ConstantBool::getFalse());
else if (I.getParent() != SI->getParent() || SI->hasOneUse())
I.setOperand(1, SI->getOperand(2));
else
@@ -2001,7 +2001,7 @@
if (ST->isNullValue()) {
Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
if (CondI && CondI->getParent() == I.getParent())
- UpdateValueUsesWith(CondI, ConstantBool::True);
+ UpdateValueUsesWith(CondI, ConstantBool::getTrue());
else if (I.getParent() != SI->getParent() || SI->hasOneUse())
I.setOperand(1, SI->getOperand(1));
else
@@ -2213,7 +2213,7 @@
if (ST->isNullValue()) {
Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
if (CondI && CondI->getParent() == I.getParent())
- UpdateValueUsesWith(CondI, ConstantBool::False);
+ UpdateValueUsesWith(CondI, ConstantBool::getFalse());
else if (I.getParent() != SI->getParent() || SI->hasOneUse())
I.setOperand(1, SI->getOperand(2));
else
@@ -2225,7 +2225,7 @@
if (ST->isNullValue()) {
Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
if (CondI && CondI->getParent() == I.getParent())
- UpdateValueUsesWith(CondI, ConstantBool::True);
+ UpdateValueUsesWith(CondI, ConstantBool::getTrue());
else if (I.getParent() != SI->getParent() || SI->hasOneUse())
I.setOperand(1, SI->getOperand(1));
else
@@ -2344,14 +2344,14 @@
/// SetCC instruction.
static Value *getSetCCValue(unsigned Opcode, Value *LHS, Value *RHS) {
switch (Opcode) {
- case 0: return ConstantBool::False;
+ case 0: return ConstantBool::getFalse();
case 1: return new SetCondInst(Instruction::SetGT, LHS, RHS);
case 2: return new SetCondInst(Instruction::SetEQ, LHS, RHS);
case 3: return new SetCondInst(Instruction::SetGE, LHS, RHS);
case 4: return new SetCondInst(Instruction::SetLT, LHS, RHS);
case 5: return new SetCondInst(Instruction::SetNE, LHS, RHS);
case 6: return new SetCondInst(Instruction::SetLE, LHS, RHS);
- case 7: return ConstantBool::True;
+ case 7: return ConstantBool::getTrue();
default: assert(0 && "Illegal SetCCCode!"); return 0;
}
}
@@ -2851,7 +2851,7 @@
default: assert(0 && "Unknown integer condition code!");
case Instruction::SetEQ: // (X == 13 & X == 15) -> false
case Instruction::SetGT: // (X == 13 & X > 15) -> false
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
case Instruction::SetNE: // (X == 13 & X != 15) -> X == 13
case Instruction::SetLT: // (X == 13 & X < 15) -> X == 13
return ReplaceInstUsesWith(I, LHS);
@@ -2886,7 +2886,7 @@
default: assert(0 && "Unknown integer condition code!");
case Instruction::SetEQ: // (X < 13 & X == 15) -> false
case Instruction::SetGT: // (X < 13 & X > 15) -> false
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
case Instruction::SetNE: // (X < 13 & X != 15) -> X < 13
case Instruction::SetLT: // (X < 13 & X < 15) -> X < 13
return ReplaceInstUsesWith(I, LHS);
@@ -3254,7 +3254,7 @@
return ReplaceInstUsesWith(I, LHS);
case Instruction::SetNE: // (X != 13 | X != 15) -> true
case Instruction::SetLT: // (X != 13 | X < 15) -> true
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
}
break;
case Instruction::SetLT:
@@ -3277,7 +3277,7 @@
return ReplaceInstUsesWith(I, LHS);
case Instruction::SetNE: // (X > 13 | X != 15) -> true
case Instruction::SetLT: // (X > 13 | X < 15) -> true
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
}
}
}
@@ -3339,7 +3339,7 @@
if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0)) {
// xor (setcc A, B), true = not (setcc A, B) = setncc A, B
if (SetCondInst *SCI = dyn_cast<SetCondInst>(Op0I))
- if (RHS == ConstantBool::True && SCI->hasOneUse())
+ if (RHS == ConstantBool::getTrue() && SCI->hasOneUse())
return new SetCondInst(SCI->getInverseCondition(),
SCI->getOperand(0), SCI->getOperand(1));
@@ -3781,9 +3781,9 @@
// Check to see if we are comparing against the minimum or maximum value...
if (CI->isMinValue()) {
if (I.getOpcode() == Instruction::SetLT) // A < MIN -> FALSE
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
if (I.getOpcode() == Instruction::SetGE) // A >= MIN -> TRUE
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
if (I.getOpcode() == Instruction::SetLE) // A <= MIN -> A == MIN
return BinaryOperator::createSetEQ(Op0, Op1);
if (I.getOpcode() == Instruction::SetGT) // A > MIN -> A != MIN
@@ -3791,9 +3791,9 @@
} else if (CI->isMaxValue()) {
if (I.getOpcode() == Instruction::SetGT) // A > MAX -> FALSE
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
if (I.getOpcode() == Instruction::SetLE) // A <= MAX -> TRUE
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
if (I.getOpcode() == Instruction::SetGE) // A >= MAX -> A == MAX
return BinaryOperator::createSetEQ(Op0, Op1);
if (I.getOpcode() == Instruction::SetLT) // A < MAX -> A != MAX
@@ -3842,19 +3842,23 @@
default: assert(0 && "Unknown setcc opcode!");
case Instruction::SetEQ:
if (Max < RHSVal || Min > RHSVal)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
case Instruction::SetNE:
if (Max < RHSVal || Min > RHSVal)
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
break;
case Instruction::SetLT:
- if (Max < RHSVal) return ReplaceInstUsesWith(I, ConstantBool::True);
- if (Min > RHSVal) return ReplaceInstUsesWith(I, ConstantBool::False);
+ if (Max < RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+ if (Min > RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
case Instruction::SetGT:
- if (Min > RHSVal) return ReplaceInstUsesWith(I, ConstantBool::True);
- if (Max < RHSVal) return ReplaceInstUsesWith(I, ConstantBool::False);
+ if (Min > RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+ if (Max < RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
}
} else { // Signed comparison.
@@ -3866,19 +3870,23 @@
default: assert(0 && "Unknown setcc opcode!");
case Instruction::SetEQ:
if (Max < RHSVal || Min > RHSVal)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
case Instruction::SetNE:
if (Max < RHSVal || Min > RHSVal)
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
break;
case Instruction::SetLT:
- if (Max < RHSVal) return ReplaceInstUsesWith(I, ConstantBool::True);
- if (Min > RHSVal) return ReplaceInstUsesWith(I, ConstantBool::False);
+ if (Max < RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+ if (Min > RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
case Instruction::SetGT:
- if (Min > RHSVal) return ReplaceInstUsesWith(I, ConstantBool::True);
- if (Max < RHSVal) return ReplaceInstUsesWith(I, ConstantBool::False);
+ if (Min > RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+ if (Max < RHSVal)
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
break;
}
}
@@ -3978,9 +3986,9 @@
// As a special case, check to see if this means that the
// result is always true or false now.
if (I.getOpcode() == Instruction::SetEQ)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
if (I.getOpcode() == Instruction::SetNE)
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
} else {
I.setOperand(1, NewCst);
Constant *NewAndCST;
@@ -4200,7 +4208,7 @@
default: assert(0 && "Unhandled setcc opcode!");
case Instruction::SetEQ:
if (LoOverflow && HiOverflow)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
else if (HiOverflow)
return new SetCondInst(Instruction::SetGE, X, LoBound);
else if (LoOverflow)
@@ -4209,7 +4217,7 @@
return InsertRangeTest(X, LoBound, HiBound, true, I);
case Instruction::SetNE:
if (LoOverflow && HiOverflow)
- return ReplaceInstUsesWith(I, ConstantBool::True);
+ return ReplaceInstUsesWith(I, ConstantBool::getTrue());
else if (HiOverflow)
return new SetCondInst(Instruction::SetLT, X, LoBound);
else if (LoOverflow)
@@ -4218,11 +4226,11 @@
return InsertRangeTest(X, LoBound, HiBound, false, I);
case Instruction::SetLT:
if (LoOverflow)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
return new SetCondInst(Instruction::SetLT, X, LoBound);
case Instruction::SetGT:
if (HiOverflow)
- return ReplaceInstUsesWith(I, ConstantBool::False);
+ return ReplaceInstUsesWith(I, ConstantBool::getFalse());
return new SetCondInst(Instruction::SetGE, X, HiBound);
}
}
@@ -4558,9 +4566,9 @@
// If the value cannot be represented in the shorter type, we cannot emit
// a simple comparison.
if (SCI.getOpcode() == Instruction::SetEQ)
- return ReplaceInstUsesWith(SCI, ConstantBool::False);
+ return ReplaceInstUsesWith(SCI, ConstantBool::getFalse());
if (SCI.getOpcode() == Instruction::SetNE)
- return ReplaceInstUsesWith(SCI, ConstantBool::True);
+ return ReplaceInstUsesWith(SCI, ConstantBool::getTrue());
// Evaluate the comparison for LT.
Value *Result;
@@ -4569,21 +4577,21 @@
if (isSignSrc) {
// Signed extend and signed comparison.
if (cast<ConstantSInt>(CI)->getValue() < 0) // X < (small) --> false
- Result = ConstantBool::False;
+ Result = ConstantBool::getFalse();
else
- Result = ConstantBool::True; // X < (large) --> true
+ Result = ConstantBool::getTrue(); // X < (large) --> true
} else {
// Unsigned extend and signed comparison.
if (cast<ConstantSInt>(CI)->getValue() < 0)
- Result = ConstantBool::False;
+ Result = ConstantBool::getFalse();
else
- Result = ConstantBool::True;
+ Result = ConstantBool::getTrue();
}
} else {
// We're performing an unsigned comparison.
if (!isSignSrc) {
// Unsigned extend & compare -> always true.
- Result = ConstantBool::True;
+ Result = ConstantBool::getTrue();
} else {
// We're performing an unsigned comp with a sign extended value.
// This is true if the input is >= 0. [aka >s -1]
@@ -5389,7 +5397,7 @@
// cast (xor bool X, true) to int --> xor (cast bool X to int), 1
if (SrcBitSize == 1 && SrcI->getOpcode() == Instruction::Xor &&
- Op1 == ConstantBool::True &&
+ Op1 == ConstantBool::getTrue() &&
(!Op0->hasOneUse() || !isa<SetCondInst>(Op0))) {
Value *New = InsertOperandCastBefore(Op0, DestTy, &CI);
return BinaryOperator::createXor(New,
@@ -5648,12 +5656,7 @@
// select true, X, Y -> X
// select false, X, Y -> Y
if (ConstantBool *C = dyn_cast<ConstantBool>(CondVal))
- if (C == ConstantBool::True)
- return ReplaceInstUsesWith(SI, TrueVal);
- else {
- assert(C == ConstantBool::False);
- return ReplaceInstUsesWith(SI, FalseVal);
- }
+ return ReplaceInstUsesWith(SI, C->getValue() ? TrueVal : FalseVal);
// select C, X, X -> X
if (TrueVal == FalseVal)
@@ -5672,7 +5675,7 @@
if (SI.getType() == Type::BoolTy)
if (ConstantBool *C = dyn_cast<ConstantBool>(TrueVal)) {
- if (C == ConstantBool::True) {
+ if (C->getValue()) {
// Change: A = select B, true, C --> A = or B, C
return BinaryOperator::createOr(CondVal, FalseVal);
} else {
@@ -5683,7 +5686,7 @@
return BinaryOperator::createAnd(NotCond, FalseVal);
}
} else if (ConstantBool *C = dyn_cast<ConstantBool>(FalseVal)) {
- if (C == ConstantBool::False) {
+ if (C->getValue() == false) {
// Change: A = select B, C, false --> A = and B, C
return BinaryOperator::createAnd(CondVal, TrueVal);
} else {
@@ -6193,7 +6196,7 @@
Instruction *OldCall = CS.getInstruction();
// If the call and callee calling conventions don't match, this call must
// be unreachable, as the call is undefined.
- new StoreInst(ConstantBool::True,
+ new StoreInst(ConstantBool::getTrue(),
UndefValue::get(PointerType::get(Type::BoolTy)), OldCall);
if (!OldCall->use_empty())
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
@@ -6206,7 +6209,7 @@
// This instruction is not reachable, just remove it. We insert a store to
// undef so that we know that this code is not reachable, despite the fact
// that we can't modify the CFG here.
- new StoreInst(ConstantBool::True,
+ new StoreInst(ConstantBool::getTrue(),
UndefValue::get(PointerType::get(Type::BoolTy)),
CS.getInstruction());
@@ -6217,7 +6220,7 @@
if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
// Don't break the CFG, insert a dummy cond branch.
new BranchInst(II->getNormalDest(), II->getUnwindDest(),
- ConstantBool::True, II);
+ ConstantBool::getTrue(), II);
}
return EraseInstFromFunction(*CS.getInstruction());
}
@@ -6901,7 +6904,7 @@
// free undef -> unreachable.
if (isa<UndefValue>(Op)) {
// Insert a new store to null because we cannot modify the CFG here.
- new StoreInst(ConstantBool::True,
+ new StoreInst(ConstantBool::getTrue(),
UndefValue::get(PointerType::get(Type::BoolTy)), &FI);
return EraseInstFromFunction(FI);
}
Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.47 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.48
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.47 Tue Aug 29 17:29:16 2006
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Sep 28 18:35:21 2006
@@ -173,7 +173,8 @@
// See if this, or some part of it, is loop invariant. If so, we can
// unswitch on it if we desire.
Value *LoopCond = FindLIVLoopCondition(BI->getCondition(), L, Changed);
- if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::True, L)) {
+ if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::getTrue(),
+ L)) {
++NumBranches;
return true;
}
@@ -196,7 +197,8 @@
BBI != E; ++BBI)
if (SelectInst *SI = dyn_cast<SelectInst>(BBI)) {
Value *LoopCond = FindLIVLoopCondition(SI->getCondition(), L, Changed);
- if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::True, L)) {
+ if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::getTrue(),
+ L)) {
++NumSelects;
return true;
}
@@ -286,9 +288,9 @@
// side-effects. If so, determine the value of Cond that causes it to do
// this.
if ((LoopExitBB = isTrivialLoopExitBlock(L, BI->getSuccessor(0)))) {
- if (Val) *Val = ConstantBool::True;
+ if (Val) *Val = ConstantBool::getTrue();
} else if ((LoopExitBB = isTrivialLoopExitBlock(L, BI->getSuccessor(1)))) {
- if (Val) *Val = ConstantBool::False;
+ if (Val) *Val = ConstantBool::getFalse();
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(HeaderTerm)) {
// If this isn't a switch on Cond, we can't handle it.
@@ -488,7 +490,7 @@
Value *BranchVal = LIC;
if (!isa<ConstantBool>(Val)) {
BranchVal = BinaryOperator::createSetEQ(LIC, Val, "tmp", InsertPt);
- } else if (Val != ConstantBool::True) {
+ } else if (Val != ConstantBool::getTrue()) {
// We want to enter the new loop when the condition is true.
std::swap(TrueDest, FalseDest);
}
@@ -964,10 +966,9 @@
BasicBlock* Split = SplitBlock(Old, SI);
Instruction* OldTerm = Old->getTerminator();
- BranchInst* Branch = new BranchInst(Split,
- SI->getSuccessor(i),
- ConstantBool::True,
- OldTerm);
+ BranchInst* Branch = new BranchInst(Split, SI->getSuccessor(i),
+ ConstantBool::getTrue(),
+ OldTerm);
Old->getTerminator()->eraseFromParent();
Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.15 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.16
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.15 Sat Sep 23 10:13:08 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp Thu Sep 28 18:35:21 2006
@@ -315,51 +315,47 @@
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V2)) {
switch (BO->getOpcode()) {
case Instruction::SetEQ:
- if (V1 == ConstantBool::True)
- add(Opcode, BO->getOperand(0), BO->getOperand(1), false);
- if (V1 == ConstantBool::False)
- add(Opcode, BO->getOperand(0), BO->getOperand(1), true);
+ if (ConstantBool *V1CB = dyn_cast<ConstantBool>(V1))
+ add(Opcode, BO->getOperand(0), BO->getOperand(1),!V1CB->getValue());
break;
case Instruction::SetNE:
- if (V1 == ConstantBool::True)
- add(Opcode, BO->getOperand(0), BO->getOperand(1), true);
- if (V1 == ConstantBool::False)
- add(Opcode, BO->getOperand(0), BO->getOperand(1), false);
+ if (ConstantBool *V1CB = dyn_cast<ConstantBool>(V1))
+ add(Opcode, BO->getOperand(0), BO->getOperand(1), V1CB->getValue());
break;
case Instruction::SetLT:
case Instruction::SetGT:
- if (V1 == ConstantBool::True)
+ if (V1 == ConstantBool::getTrue())
add(Opcode, BO->getOperand(0), BO->getOperand(1), true);
break;
case Instruction::SetLE:
case Instruction::SetGE:
- if (V1 == ConstantBool::False)
+ if (V1 == ConstantBool::getFalse())
add(Opcode, BO->getOperand(0), BO->getOperand(1), true);
break;
case Instruction::And:
- if (V1 == ConstantBool::True) {
- add(Opcode, ConstantBool::True, BO->getOperand(0), false);
- add(Opcode, ConstantBool::True, BO->getOperand(1), false);
+ if (V1 == ConstantBool::getTrue()) {
+ add(Opcode, V1, BO->getOperand(0), false);
+ add(Opcode, V1, BO->getOperand(1), false);
}
break;
case Instruction::Or:
- if (V1 == ConstantBool::False) {
- add(Opcode, ConstantBool::False, BO->getOperand(0), false);
- add(Opcode, ConstantBool::False, BO->getOperand(1), false);
+ if (V1 == ConstantBool::getFalse()) {
+ add(Opcode, V1, BO->getOperand(0), false);
+ add(Opcode, V1, BO->getOperand(1), false);
}
break;
case Instruction::Xor:
- if (V1 == ConstantBool::True) {
- if (BO->getOperand(0) == ConstantBool::True)
- add(Opcode, ConstantBool::False, BO->getOperand(1), false);
- if (BO->getOperand(1) == ConstantBool::True)
- add(Opcode, ConstantBool::False, BO->getOperand(0), false);
+ if (V1 == ConstantBool::getTrue()) {
+ if (BO->getOperand(0) == V1)
+ add(Opcode, ConstantBool::getFalse(), BO->getOperand(1), false);
+ if (BO->getOperand(1) == V1)
+ add(Opcode, ConstantBool::getFalse(), BO->getOperand(0), false);
}
- if (V1 == ConstantBool::False) {
- if (BO->getOperand(0) == ConstantBool::True)
- add(Opcode, ConstantBool::True, BO->getOperand(1), false);
- if (BO->getOperand(1) == ConstantBool::True)
- add(Opcode, ConstantBool::True, BO->getOperand(0), false);
+ if (V1 == ConstantBool::getFalse()) {
+ if (BO->getOperand(0) == ConstantBool::getTrue())
+ add(Opcode, ConstantBool::getTrue(), BO->getOperand(1), false);
+ if (BO->getOperand(1) == ConstantBool::getTrue())
+ add(Opcode, ConstantBool::getTrue(), BO->getOperand(0), false);
}
break;
default:
@@ -368,10 +364,8 @@
} else if (SelectInst *SI = dyn_cast<SelectInst>(V2)) {
if (Opcode != EQ && Opcode != NE) return;
- ConstantBool *True = (Opcode==EQ) ? ConstantBool::True
- : ConstantBool::False,
- *False = (Opcode==EQ) ? ConstantBool::False
- : ConstantBool::True;
+ ConstantBool *True = ConstantBool::get(Opcode==EQ),
+ *False = ConstantBool::get(Opcode!=EQ);
if (V1 == SI->getTrueValue())
addEqual(SI->getCondition(), True);
@@ -525,8 +519,8 @@
if (NE != KP.Properties.end()) {
switch (SCI->getOpcode()) {
- case Instruction::SetEQ: return ConstantBool::False;
- case Instruction::SetNE: return ConstantBool::True;
+ case Instruction::SetEQ: return ConstantBool::getFalse();
+ case Instruction::SetNE: return ConstantBool::getTrue();
case Instruction::SetLE:
case Instruction::SetGE:
case Instruction::SetLT:
@@ -558,10 +552,9 @@
Value *PredicateSimplifier::resolve(SelectInst *SI, const PropertySet &KP) {
Value *Condition = resolve(SI->getCondition(), KP);
- if (Condition == ConstantBool::True)
- return resolve(SI->getTrueValue(), KP);
- else if (Condition == ConstantBool::False)
- return resolve(SI->getFalseValue(), KP);
+ if (ConstantBool *CB = dyn_cast<ConstantBool>(Condition))
+ return resolve(CB->getValue() ? SI->getTrueValue() : SI->getFalseValue(),
+ KP);
return SI;
}
@@ -674,10 +667,10 @@
BasicBlock *TrueDest = BI->getSuccessor(0),
*FalseDest = BI->getSuccessor(1);
- if (Condition == ConstantBool::True || TrueDest == FalseDest) {
+ if (Condition == ConstantBool::getTrue() || TrueDest == FalseDest) {
proceedToSuccessors(KP, BB);
return;
- } else if (Condition == ConstantBool::False) {
+ } else if (Condition == ConstantBool::getFalse()) {
proceedToSuccessors(KP, BB);
return;
}
@@ -686,14 +679,14 @@
for (DTNodeType::iterator I = Node->begin(), E = Node->end(); I != E; ++I) {
if ((*I)->getBlock() == TrueDest) {
PropertySet TrueProperties(KP);
- TrueProperties.addEqual(ConstantBool::True, Condition);
+ TrueProperties.addEqual(ConstantBool::getTrue(), Condition);
proceedToSuccessor(BI, 0, KP, TrueProperties);
continue;
}
if ((*I)->getBlock() == FalseDest) {
PropertySet FalseProperties(KP);
- FalseProperties.addEqual(ConstantBool::False, Condition);
+ FalseProperties.addEqual(ConstantBool::getFalse(), Condition);
proceedToSuccessor(BI, 1, KP, FalseProperties);
continue;
}
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.131 llvm/lib/Transforms/Scalar/SCCP.cpp:1.132
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.131 Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/SCCP.cpp Thu Sep 28 18:35:21 2006
@@ -374,7 +374,7 @@
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::False] = true;
+ Succs[BCValue.getConstant() == ConstantBool::getFalse()] = true;
}
}
} else if (InvokeInst *II = dyn_cast<InvokeInst>(&TI)) {
@@ -432,7 +432,7 @@
// Constant condition variables mean the branch can only go a single way
return BI->getSuccessor(BCValue.getConstant() ==
- ConstantBool::False) == To;
+ ConstantBool::getFalse()) == To;
}
return false;
}
@@ -598,12 +598,9 @@
if (CondValue.isUndefined())
return;
if (CondValue.isConstant()) {
- Value *InVal = 0;
- if (CondValue.getConstant() == ConstantBool::True) {
- mergeInValue(&I, getValueState(I.getTrueValue()));
- return;
- } else if (CondValue.getConstant() == ConstantBool::False) {
- mergeInValue(&I, getValueState(I.getFalseValue()));
+ if (ConstantBool *CondCB = dyn_cast<ConstantBool>(CondValue.getConstant())){
+ mergeInValue(&I, getValueState(CondCB->getValue() ? I.getTrueValue()
+ : I.getFalseValue()));
return;
}
}
@@ -1035,7 +1032,7 @@
if (BI->isConditional()) {
LatticeVal &BCValue = getValueState(BI->getCondition());
if (BCValue.isUndefined()) {
- BI->setCondition(ConstantBool::True);
+ BI->setCondition(ConstantBool::getTrue());
BranchesResolved = true;
visit(BI);
}
More information about the llvm-commits
mailing list