diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 21 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/RSProfiling.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/CondPropagate.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Scalar/CorrelatedExprs.cpp | 156 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 218 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 64 | ||||
-rw-r--r-- | lib/Transforms/Scalar/PredicateSimplifier.cpp | 57 | ||||
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/Utils/CloneFunction.cpp | 13 | ||||
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 13 | ||||
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 2 |
14 files changed, 304 insertions, 283 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index f25621eb78..c1944dbe95 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -711,7 +711,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, // keep track of whether the global was initialized yet or not. GlobalVariable *InitBool = new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage, - ConstantBool::getFalse(), GV->getName()+".init"); + ConstantInt::getFalse(), GV->getName()+".init"); bool InitBoolUsed = false; // Loop over all uses of GV, processing them in turn. @@ -731,7 +731,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, default: assert(0 && "Unknown ICmp Predicate!"); case ICmpInst::ICMP_ULT: case ICmpInst::ICMP_SLT: - LV = ConstantBool::getFalse(); // X < null -> always false + LV = ConstantInt::getFalse(); // X < null -> always false break; case ICmpInst::ICMP_ULE: case ICmpInst::ICMP_SLE: @@ -753,7 +753,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, } else { StoreInst *SI = cast<StoreInst>(GV->use_back()); // The global is initialized when the store to it occurs. - new StoreInst(ConstantBool::getTrue(), InitBool, SI); + new StoreInst(ConstantInt::getTrue(), InitBool, SI); SI->eraseFromParent(); } @@ -1140,7 +1140,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { // Create the new global, initializing it to false. GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false, - GlobalValue::InternalLinkage, ConstantBool::getFalse(), + GlobalValue::InternalLinkage, ConstantInt::getFalse(), GV->getName()+".b"); GV->getParent()->getGlobalList().insert(GV, NewGV); @@ -1161,7 +1161,7 @@ static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { // Only do this if we weren't storing a loaded value. Value *StoreVal; if (StoringOther || SI->getOperand(0) == InitVal) - StoreVal = ConstantBool::get(StoringOther); + StoreVal = ConstantInt::get(StoringOther); else { // Otherwise, we are storing a previously loaded copy. To do this, // change the copy from copying the original value to just copying the @@ -1797,10 +1797,13 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal, if (BI->isUnconditional()) { NewBB = BI->getSuccessor(0); } else { - ConstantBool *Cond = - dyn_cast<ConstantBool>(getVal(Values, BI->getCondition())); - if (!Cond) return false; // Cannot determine. - NewBB = BI->getSuccessor(!Cond->getValue()); + ConstantInt *Cond = + dyn_cast<ConstantInt>(getVal(Values, BI->getCondition())); + + // Cannot determine. + if (!Cond || Cond->getType() != Type::BoolTy) + return false; + NewBB = BI->getSuccessor(!Cond->getBoolValue()); } } else if (SwitchInst *SI = dyn_cast<SwitchInst>(CurInst)) { ConstantInt *Val = diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index e70a2cbbe0..5c0aa36361 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -460,7 +460,7 @@ void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F) //b: new BranchInst(cast<BasicBlock>(Translate(dst)), bbC); new BranchInst(dst, cast<BasicBlock>(Translate(dst)), - ConstantBool::get(true), bbCp); + ConstantInt::get(true), bbCp); //c: { TerminatorInst* iB = src->getTerminator(); @@ -516,7 +516,7 @@ bool ProfilerRS::runOnFunction(Function& F) { TerminatorInst* T = F.getEntryBlock().getTerminator(); ReplaceInstWithInst(T, new BranchInst(T->getSuccessor(0), cast<BasicBlock>(Translate(T->getSuccessor(0))), - ConstantBool::get(true))); + ConstantInt::get(true))); //do whatever is needed now that the function is duplicated c->PrepFunction(&F); diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp index 49a849625b..4ca5c5e7b7 100644 --- a/lib/Transforms/Scalar/CondPropagate.cpp +++ b/lib/Transforms/Scalar/CondPropagate.cpp @@ -133,12 +133,13 @@ void CondProp::SimplifyPredecessors(BranchInst *BI) { // constants. Walk from the end to remove operands from the end when // possible, and to avoid invalidating "i". for (unsigned i = PN->getNumIncomingValues(); i != 0; --i) - if (ConstantBool *CB = dyn_cast<ConstantBool>(PN->getIncomingValue(i-1))) { + if (ConstantInt *CB = dyn_cast<ConstantInt>(PN->getIncomingValue(i-1))) { + if (CB->getType() != Type::BoolTy) continue; // If we have a constant, forward the edge from its current to its // ultimate destination. bool PHIGone = PN->getNumIncomingValues() == 2; RevectorBlockTo(PN->getIncomingBlock(i-1), - BI->getSuccessor(CB->getValue() == 0)); + BI->getSuccessor(CB->getBoolValue() == 0)); ++NumBrThread; // If there were two predecessors before this simplification, the PHI node diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 203b7fa238..44d3ad5cc2 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -472,7 +472,7 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo, } else if (CmpInst *CI = dyn_cast<CmpInst>(I)) { Relation::KnownResult Res = getCmpResult(CI, NewRI); if (Res == Relation::Unknown) return false; - PropagateEquality(CI, ConstantBool::get(Res), NewRI); + PropagateEquality(CI, ConstantInt::get(Res), NewRI); } else { assert(isa<BranchInst>(*I) && "Unexpected instruction type!"); } @@ -484,10 +484,11 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo, if (PredicateVI.getReplacement() && isa<Constant>(PredicateVI.getReplacement()) && !isa<GlobalValue>(PredicateVI.getReplacement())) { - ConstantBool *CB = cast<ConstantBool>(PredicateVI.getReplacement()); + ConstantInt *CB = cast<ConstantInt>(PredicateVI.getReplacement()); // Forward to the successor that corresponds to the branch we will take. - ForwardSuccessorTo(TI, SuccNo, BI->getSuccessor(!CB->getValue()), NewRI); + ForwardSuccessorTo(TI, SuccNo, + BI->getSuccessor(!CB->getBoolValue()), NewRI); return true; } @@ -782,12 +783,12 @@ void CEE::PropagateBranchInfo(BranchInst *BI) { // Propagate information into the true block... // - PropagateEquality(BI->getCondition(), ConstantBool::getTrue(), + PropagateEquality(BI->getCondition(), ConstantInt::getTrue(), getRegionInfo(BI->getSuccessor(0))); // Propagate information into the false block... // - PropagateEquality(BI->getCondition(), ConstantBool::getFalse(), + PropagateEquality(BI->getCondition(), ConstantInt::getFalse(), getRegionInfo(BI->getSuccessor(1))); } @@ -832,78 +833,79 @@ void CEE::PropagateEquality(Value *Op0, Value *Op1, RegionInfo &RI) { // it's a constant, then see if the other one is one of a setcc instruction, // an AND, OR, or XOR instruction. // - if (ConstantBool *CB = dyn_cast<ConstantBool>(Op1)) { - - if (Instruction *Inst = dyn_cast<Instruction>(Op0)) { - // If we know that this instruction is an AND instruction, and the result - // is true, this means that both operands to the OR are known to be true - // as well. - // - if (CB->getValue() && Inst->getOpcode() == Instruction::And) { - PropagateEquality(Inst->getOperand(0), CB, RI); - PropagateEquality(Inst->getOperand(1), CB, RI); - } - - // If we know that this instruction is an OR instruction, and the result - // is false, this means that both operands to the OR are know to be false - // as well. - // - if (!CB->getValue() && Inst->getOpcode() == Instruction::Or) { - PropagateEquality(Inst->getOperand(0), CB, RI); - PropagateEquality(Inst->getOperand(1), CB, RI); - } - - // If we know that this instruction is a NOT instruction, we know that the - // operand is known to be the inverse of whatever the current value is. - // - if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Inst)) - if (BinaryOperator::isNot(BOp)) - PropagateEquality(BinaryOperator::getNotArgument(BOp), - ConstantBool::get(!CB->getValue()), RI); + if (Op1->getType() == Type::BoolTy) + if (ConstantInt *CB = dyn_cast<ConstantInt>(Op1)) { + + if (Instruction *Inst = dyn_cast<Instruction>(Op0)) { + // If we know that this instruction is an AND instruction, and the result + // is true, this means that both operands to the OR are known to be true + // as well. + // + if (CB->getBoolValue() && Inst->getOpcode() == Instruction::And) { + PropagateEquality(Inst->getOperand(0), CB, RI); + PropagateEquality(Inst->getOperand(1), CB, RI); + } + + // If we know that this instruction is an OR instruction, and the result + // is false, this means that both operands to the OR are know to be false + // as well. + // + if (!CB->getBoolValue() && Inst->getOpcode() == Instruction::Or) { + PropagateEquality(Inst->getOperand(0), CB, RI); + PropagateEquality(Inst->getOperand(1), CB, RI); + } - // If we know the value of a FCmp instruction, propagate the information - // about the relation into this region as well. - // - if (FCmpInst *FCI = dyn_cast<FCmpInst>(Inst)) { - if (CB->getValue()) { // If we know the condition is true... - // Propagate info about the LHS to the RHS & RHS to LHS - PropagateRelation(FCI->getPredicate(), FCI->getOperand(0), - FCI->getOperand(1), RI); - PropagateRelation(FCI->getSwappedPredicate(), - FCI->getOperand(1), FCI->getOperand(0), RI); - - } else { // If we know the condition is false... - // We know the opposite of the condition is true... - FCmpInst::Predicate C = FCI->getInversePredicate(); - - PropagateRelation(C, FCI->getOperand(0), FCI->getOperand(1), RI); - PropagateRelation(FCmpInst::getSwappedPredicate(C), - FCI->getOperand(1), FCI->getOperand(0), RI); + // If we know that this instruction is a NOT instruction, we know that the + // operand is known to be the inverse of whatever the current value is. + // + if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Inst)) + if (BinaryOperator::isNot(BOp)) + PropagateEquality(BinaryOperator::getNotArgument(BOp), + ConstantInt::get(!CB->getBoolValue()), RI); + + // If we know the value of a FCmp instruction, propagate the information + // about the relation into this region as well. + // + if (FCmpInst *FCI = dyn_cast<FCmpInst>(Inst)) { + if (CB->getBoolValue()) { // If we know the condition is true... + // Propagate info about the LHS to the RHS & RHS to LHS + PropagateRelation(FCI->getPredicate(), FCI->getOperand(0), + FCI->getOperand(1), RI); + PropagateRelation(FCI->getSwappedPredicate(), + FCI->getOperand(1), FCI->getOperand(0), RI); + + } else { // If we know the condition is false... + // We know the opposite of the condition is true... + FCmpInst::Predicate C = FCI->getInversePredicate(); + + PropagateRelation(C, FCI->getOperand(0), FCI->getOperand(1), RI); + PropagateRelation(FCmpInst::getSwappedPredicate(C), + FCI->getOperand(1), FCI->getOperand(0), RI); + } } - } - // If we know the value of a ICmp instruction, propagate the information - // about the relation into this region as well. - // - if (ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) { - if (CB->getValue()) { // If we know the condition is true... - // Propagate info about the LHS to the RHS & RHS to LHS - PropagateRelation(ICI->getPredicate(), ICI->getOperand(0), - ICI->getOperand(1), RI); - PropagateRelation(ICI->getSwappedPredicate(), ICI->getOperand(1), - ICI->getOperand(1), RI); - - } else { // If we know the condition is false ... - // We know the opposite of the condition is true... - ICmpInst::Predicate C = ICI->getInversePredicate(); - - PropagateRelation(C, ICI->getOperand(0), ICI->getOperand(1), RI); - PropagateRelation(ICmpInst::getSwappedPredicate(C), - ICI->getOperand(1), ICI->getOperand(0), RI); + // If we know the value of a ICmp instruction, propagate the information + // about the relation into this region as well. + // + if (ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) { + if (CB->getBoolValue()) { // If we know the condition is true... + // Propagate info about the LHS to the RHS & RHS to LHS + PropagateRelation(ICI->getPredicate(), ICI->getOperand(0), + ICI->getOperand(1), RI); + PropagateRelation(ICI->getSwappedPredicate(), ICI->getOperand(1), + ICI->getOperand(1), RI); + + } else { // If we know the condition is false ... + // We know the opposite of the condition is true... + ICmpInst::Predicate C = ICI->getInversePredicate(); + + PropagateRelation(C, ICI->getOperand(0), ICI->getOperand(1), RI); + PropagateRelation(ICmpInst::getSwappedPredicate(C), + ICI->getOperand(1), ICI->getOperand(0), RI); + } } } } - } // Propagate information about Op0 to Op1 & visa versa PropagateRelation(ICmpInst::ICMP_EQ, Op0, Op1, RI); @@ -992,7 +994,7 @@ void CEE::IncorporateInstruction(Instruction *Inst, RegionInfo &RI) { // See if we can figure out a result for this instruction... Relation::KnownResult Result = getCmpResult(CI, RI); if (Result != Relation::Unknown) { - PropagateEquality(CI, ConstantBool::get(Result != 0), RI); + PropagateEquality(CI, ConstantInt::get(Result != 0), RI); } } } @@ -1066,7 +1068,7 @@ bool CEE::SimplifyBasicBlock(BasicBlock &BB, const RegionInfo &RI) { DEBUG(cerr << "Replacing icmp with " << Result << " constant: " << *CI); - CI->replaceAllUsesWith(ConstantBool::get((bool)Result)); + CI->replaceAllUsesWith(ConstantInt::get((bool)Result)); // The instruction is now dead, remove it from the program. CI->getParent()->getInstList().erase(CI); ++NumCmpRemoved; @@ -1120,7 +1122,7 @@ Relation::KnownResult CEE::getCmpResult(CmpInst *CI, if (Constant *Result = ConstantFoldInstruction(CI)) { // Wow, this is easy, directly eliminate the ICmpInst. DEBUG(cerr << "Replacing cmp with constant fold: " << *CI); - return cast<ConstantBool>(Result)->getValue() + return cast<ConstantInt>(Result)->getBoolValue() ? Relation::KnownTrue : Relation::KnownFalse; } } else { @@ -1143,7 +1145,7 @@ Relation::KnownResult CEE::getCmpResult(CmpInst *CI, // Op1. Check to see if we know anything about comparing value with a // constant, and if we can use this info to fold the icmp. // - if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Op1)) { + if (ConstantInt *C = dyn_cast<ConstantInt>(Op1)) { // Check to see if we already know the result of this comparison... ConstantRange R = ConstantRange(predicate, C); ConstantRange Int = R.intersectWith(Op0VI->getBounds(), @@ -1189,7 +1191,7 @@ bool Relation::contradicts(unsigned Op, // If this is a relationship with a constant, make sure that this relationship // does not contradict properties known about the bounds of the constant. // - if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Val)) + if (ConstantInt *C = dyn_cast<ConstantInt>(Val)) if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && Op <= ICmpInst::LAST_ICMP_PREDICATE) if (ConstantRange(Op, C).intersectWith(VI.getBounds(), @@ -1247,7 +1249,7 @@ bool Relation::incorporate(unsigned Op, ValueInfo &VI) { // If this is a relationship with a constant, make sure that we update the // range that is possible for the value to have... // - if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Val)) + if (ConstantInt *C = dyn_cast<ConstantInt>(Val)) if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && Op <= ICmpInst::LAST_ICMP_PREDICATE) VI.getBounds() = ConstantRange(Op, C).intersectWith(VI.getBounds(), diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index c8b38b8603..e82f373801 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -302,10 +302,10 @@ namespace { Instruction *FoldPHIArgBinOpIntoPHI(PHINode &PN); - Instruction *OptAndOp(Instruction *Op, ConstantIntegral *OpRHS, - ConstantIntegral *AndRHS, BinaryOperator &TheAnd); + Instruction *OptAndOp(Instruction *Op, ConstantInt *OpRHS, + ConstantInt *AndRHS, BinaryOperator &TheAnd); - Value *FoldLogicalPlusAnd(Value *LHS, Value *RHS, ConstantIntegral *Mask, + Value *FoldLogicalPlusAnd(Value *LHS, Value *RHS, ConstantInt *Mask, bool isSub, Instruction &I); Instruction *InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, bool isSigned, bool Inside, Instruction &IB); @@ -484,7 +484,7 @@ static inline Value *dyn_castNotVal(Value *V) { return BinaryOperator::getNotArgument(V); // Constants can be considered to be not'ed values... - if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(V)) + if (ConstantInt *C = dyn_cast<ConstantInt>(V)) return ConstantExpr::getNot(C); return 0; } @@ -531,14 +531,6 @@ static ConstantInt *SubOne(ConstantInt *C) { ConstantInt::get(C->getType(), 1))); } -/// GetConstantInType - Return a ConstantInt with the specified type and value. -/// -static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) { - if (Ty->getTypeID() == Type::BoolTyID) - return ConstantBool::get(Val); - return ConstantInt::get(Ty, Val); -} - /// ComputeMaskedBits - Determine which of the bits specified in Mask are /// known to be either zero or one and return them in the KnownZero/KnownOne @@ -552,7 +544,7 @@ static void ComputeMaskedBits(Value *V, uint64_t Mask, uint64_t &KnownZero, // optimized based on the contradictory assumption that it is non-zero. // Because instcombine aggressively folds operations with undef args anyway, // this won't lose us code quality. - if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V)) { + if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { // We know all of the bits for a constant! KnownOne = CI->getZExtValue() & Mask; KnownZero = ~KnownOne & Mask; @@ -763,7 +755,7 @@ static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, // This is producing any bits that are not needed, shrink the RHS. uint64_t Val = Demanded & OpC->getZExtValue(); - I->setOperand(OpNo, GetConstantInType(OpC->getType(), Val)); + I->setOperand(OpNo, ConstantInt::get(OpC->getType(), Val)); return true; } @@ -824,7 +816,7 @@ static void ComputeUnsignedMinMaxValuesFromKnownBits(const Type *Ty, bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask, uint64_t &KnownZero, uint64_t &KnownOne, unsigned Depth) { - if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V)) { + if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { // We know all of the bits for a constant! KnownOne = CI->getZExtValue() & DemandedMask; KnownZero = ~KnownOne & DemandedMask; @@ -965,8 +957,8 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask, // e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2 if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask) { // all known if ((KnownOne & KnownOne2) == KnownOne) { - Constant *AndC = GetConstantInType(I->getType(), - ~KnownOne & DemandedMask); + Constant *AndC = ConstantInt::get(I->getType(), + ~KnownOne & DemandedMask); Instruction *And = BinaryOperator::createAnd(I->getOperand(0), AndC, "tmp"); InsertNewInstBefore(And, *I); @@ -1250,7 +1242,7 @@ bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask, // If the client is only demanding bits that we know, return the known // constant. if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask) - return UpdateValueUsesWith(I, GetConstantInType(I->getType(), KnownOne)); + return UpdateValueUsesWith(I, ConstantInt::get(I->getType(), KnownOne)); return false; } @@ -2280,7 +2272,7 @@ Instruction *InstCombiner::commonDivTransforms(BinaryOperator &I) { if (ST->isNullValue()) { Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0)); if (CondI && CondI->getParent() == I.getParent()) - UpdateValueUsesWith(CondI, ConstantBool::getFalse()); + UpdateValueUsesWith(CondI, ConstantInt::getFalse()); else if (I.getParent() != SI->getParent() || SI->hasOneUse()) I.setOperand(1, SI->getOperand(2)); else @@ -2293,7 +2285,7 @@ Instruction *InstCombiner::commonDivTransforms(BinaryOperator &I) { if (ST->isNullValue()) { Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0)); if (CondI && CondI->getParent() == I.getParent()) - UpdateValueUsesWith(CondI, ConstantBool::getTrue()); + UpdateValueUsesWith(CondI, ConstantInt::getTrue()); else if (I.getParent() != SI->getParent() || SI->hasOneUse()) I.setOperand(1, SI->getOperand(1)); else @@ -2513,7 +2505,7 @@ Instruction *InstCombiner::commonRemTransforms(BinaryOperator &I) { if (ST->isNullValue()) { Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0)); if (CondI && CondI->getParent() == I.getParent()) - UpdateValueUsesWith(CondI, ConstantBool::getFalse()); + UpdateValueUsesWith(CondI, ConstantInt::getFalse()); else if (I.getParent() != SI->getParent() || SI->hasOneUse()) I.setOperand(1, SI->getOperand(2)); else @@ -2525,7 +2517,7 @@ Instruction *InstCombiner::commonRemTransforms(BinaryOperator &I) { if (ST->isNullValue()) { Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0)); if (CondI && CondI->getParent() == I.getParent()) - UpdateValueUsesWith(CondI, ConstantBool::getTrue()); + UpdateValueUsesWith(CondI, ConstantInt::getTrue()); else if (I.getParent() != SI->getParent() || SI->hasOneUse()) I.setOperand(1, SI->getOperand(1)); else @@ -2758,7 +2750,7 @@ static unsigned getICmpCode(const ICmpInst *ICI) { static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS) { switch (code) { default: assert(0 && "Illegal ICmp code!"); - case 0: return ConstantBool::getFalse(); + case 0: return ConstantInt::getFalse(); case 1: if (sign) return new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS); @@ -2781,7 +2773,7 @@ static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS) { return new ICmpInst(ICmpInst::ICMP_SLE, LHS, RHS); else return new ICmpInst(ICmpInst::ICMP_ULE, LHS, RHS); - case 7: return ConstantBool::getTrue(); + case 7: return ConstantInt::getTrue(); } } @@ -2839,8 +2831,8 @@ struct FoldICmpLogical { // the Op parameter is 'OP', OpRHS is 'C1', and AndRHS is 'C2'. Op is // guaranteed to be either a shift instruction or a binary operator. Instruction *InstCombiner::OptAndOp(Instruction *Op, - ConstantIntegral *OpRHS, - ConstantIntegral *AndRHS, + ConstantInt *OpRHS, + ConstantInt *AndRHS, BinaryOperator &TheAnd) { Value *X = Op->getOperand(0); Constant *Together = 0; @@ -2911,7 +2903,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // We know that the AND will not produce any of the bits shifted in, so if // the anded constant includes them, clear them now! // - Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType()); + Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType()); Constant *ShlMask = ConstantExpr::getShl(AllOne, OpRHS); Constant *CI = ConstantExpr::getAnd(AndRHS, ShlMask); @@ -2929,7 +2921,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // the anded constant includes them, clear them now! This only applies to // unsigned shifts, because a signed shr may bring in set bits! // - Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType()); + Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType()); Constant *ShrMask = ConstantExpr::getLShr(AllOne, OpRHS); Constant *CI = ConstantExpr::getAnd(AndRHS, ShrMask); @@ -2946,7 +2938,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, // See if this is shifting in some sign extension, then masking it out // with an and. if (Op->hasOneUse()) { - Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType()); + Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType()); Constant *ShrMask = ConstantExpr::getLShr(AllOne, OpRHS); Constant *C = ConstantExpr::getAnd(AndRHS, ShrMask); if (C == AndRHS) { // Masking out bits shifted in. @@ -2972,8 +2964,8 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, bool isSigned, bool Inside, Instruction &IB) { - assert(cast<ConstantBool>(ConstantExpr::getICmp((isSigned ? - ICmpInst::ICMP_SLE:ICmpInst::ICMP_ULE), Lo, Hi))->getValue() && + assert(cast<ConstantInt>(ConstantExpr::getICmp((isSigned ? + ICmpInst::ICMP_SLE:ICmpInst::ICMP_ULE), Lo, Hi))->getBoolValue() && "Lo is not <= Hi in range emission code!"); if (Inside) { @@ -2981,7 +2973,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, return new ICmpInst(ICmpInst::ICMP_NE, V, V); // V >= Min && V < Hi --> V < Hi - if (cast<ConstantIntegral>(Lo)->isMinValue(isSigned)) { + if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) { ICmpInst::Predicate pred = (isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT); return new ICmpInst(pred, V, Hi); @@ -3000,7 +2992,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, // V < Min || V >= Hi ->'V > Hi-1' Hi = SubOne(cast<ConstantInt>(Hi)); - if (cast<ConstantIntegral>(Lo)->isMinValue(isSigned)) { + if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) { ICmpInst::Predicate pred = (isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT); return new ICmpInst(pred, V, Hi); @@ -3018,7 +3010,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi, // any number of 0s on either side. The 1s are allowed to wrap from LSB to // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is // not, since all 1s are not contiguous. -static bool isRunOfOnes(ConstantIntegral *Val, unsigned &MB, unsigned &ME) { +static bool isRunOfOnes(ConstantInt *Val, unsigned &MB, unsigned &ME) { uint64_t V = Val->getZExtValue(); if (!isShiftedMask_64(V)) return false; @@ -3042,7 +3034,7 @@ static bool isRunOfOnes(ConstantIntegral *Val, unsigned &MB, unsigned &ME) { /// return (A +/- B). /// Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS, - ConstantIntegral *Mask, bool isSub, + ConstantInt *Mask, bool isSub, Instruction &I) { Instruction *LHSI = dyn_cast<Instruction>(LHS); if (!LHSI || LHSI->getNumOperands() != 2 || @@ -3106,7 +3098,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { KnownZero, KnownOne)) return &I; - if (ConstantIntegral *AndRHS = dyn_cast<ConstantIntegral>(Op1)) { + if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(Op1)) { uint64_t AndRHSMask = AndRHS->getZExtValue(); uint64_t TypeMask = Op0->getType()->getIntegralTypeMask(); uint64_t NotAndRHS = AndRHSMask^TypeMask; @@ -3272,7 +3264,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst); ICmpInst *LHS = cast<ICmpInst>(Op0); - if (cast<ConstantBool>(Cmp)->getValue()) { + if (cast<ConstantInt>(Cmp)->getBoolValue()) { std::swap(LHS, RHS); std::swap(LHSCst, RHSCst); std::swap(LHSCC, RHSCC); @@ -3294,7 +3286,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { case ICmpInst::ICMP_EQ: // (X == 13 & X == 15) -> false case ICmpInst::ICMP_UGT: // (X == 13 & X > 15) -> false case ICmpInst::ICMP_SGT: // (X == 13 & X > 15) -> false - return ReplaceInstUsesWith(I, ConstantBool::getFalse()); + return ReplaceInstUsesWith(I, ConstantInt::getFalse()); case ICmpInst::ICMP_NE: // (X == 13 & X != 15) -> X == 13 case ICmpInst::ICMP_ULT: // (X == 13 & X < 15) -> X == 13 case ICmpInst::ICMP_SLT: // (X == 13 & X < 15) -> X == 13 @@ -3331,7 +3323,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { default: assert(0 && "Unknown integer condition code!"); case ICmpInst::ICMP_EQ: // (X u< 13 & X == 15) -> false case ICmpInst::ICMP_UGT: // (X u< 13 & X u> 15) -> false - return ReplaceInstUsesWith(I, ConstantBool::getFalse()); + return ReplaceInstUsesWith(I, ConstantInt::getFalse()); case ICmpInst::ICMP_SGT: // (X u< 13 & X s> 15) -> no change break; case ICmpInst::ICMP_NE: // (X u< 13 & X != 15) -> X u< 13 @@ -3346,7 +3338,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { default: assert(0 && "Unknown integer condition code!"); case ICmpInst::ICMP_EQ: // (X s< 13 & X == 15) -> false case ICmpInst::ICMP_SGT: // (X s< 13 & X s> 15) -> false - return ReplaceInstUsesWith(I, ConstantBool::getFalse()); + return ReplaceInstUsesWith(I, ConstantInt::getFalse()); case ICmpInst::ICMP_UGT: // (X s< 13 & X u> 15) -> no change break; case ICmpInst::ICMP_NE: // (X s< 13 & X != 15) -> X < 13 @@ -3563,7 +3555,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (isa<UndefValue>(Op1)) return ReplaceInstUsesWith(I, // X | undef -> -1 - ConstantIntegral::getAllOnesValue(I.getType())); + ConstantInt::getAllOnesValue(I.getType())); // or X, X = X if (Op0 == Op1) @@ -3578,7 +3570,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { return &I; // or X, -1 == -1 - if (ConstantIntegral *RHS = dyn_cast<ConstantIntegral>(Op1)) { + if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) { ConstantInt *C1 = 0; Value *X = 0; // (X & C1) | C2 --> (X | C2) & (C1|C2) if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) && isOnlyUse(Op0)) { @@ -3692,7 +3684,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (match(Op0, m_Not(m_Value(A)))) { // ~A | Op1 if (A == Op1) // ~A | A == -1 return ReplaceInstUsesWith(I, - ConstantIntegral::getAllOnesValue(I.getType())); + ConstantInt::getAllOnesValue(I.getType())); } else { A = 0; } @@ -3700,7 +3692,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (match(Op1, m_Not(m_Value(B)))) { // Op0 | ~B if (Op0 == B) return ReplaceInstUsesWith(I, - ConstantIntegral::getAllOnesValue(I.getType())); + ConstantInt::getAllOnesValue(I.getType())); // (~A | ~B) == (~(A & B)) - De Morgan's Law if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) { @@ -3731,7 +3723,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT; Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst); ICmpInst *LHS = cast<ICmpInst>(Op0); - if (cast<ConstantBool>(Cmp)->getValue()) { + if (cast<ConstantInt>(Cmp)->getBoolValue()) { std::swap(LHS, RHS); std::swap(LHSCst, RHSCst); std::swap(LHSCC, RHSCC); @@ -3779,7 +3771,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { case ICmpInst::ICMP_NE: // (X != 13 | X != 15) -> true case ICmpInst::ICMP_ULT: // (X != 13 | X u< 15) -> true case ICmpInst::ICMP_SLT: // (X != 13 | X s< 15) -> true - return ReplaceInstUsesWith(I, ConstantBool::getTrue()); + return ReplaceInstUsesWith(I, ConstantInt::getTrue()); } break; case ICmpInst::ICMP_ULT: @@ -3826,7 +3818,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { break; case ICmpInst::ICMP_NE: // (X u> 13 | X != 15) -> true case ICmpInst::ICMP_ULT: // (X u> 13 | X u< 15) -> true - return ReplaceInstUsesWith(I, ConstantBool::getTrue()); + return ReplaceInstUsesWith(I, ConstantInt::getTrue()); case ICmpInst::ICMP_SLT: // (X u> 13 | X s< 15) -> no change break; } @@ -3841,7 +3833,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { break; case ICmpInst::ICMP_NE: // (X s> 13 | X != 15) -> true |