diff options
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 52 | ||||
-rw-r--r-- | lib/Transforms/Scalar/PredicateSimplifier.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SimplifyLibCalls.cpp | 2 |
5 files changed, 38 insertions, 32 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 99f315f..4397540 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2107,7 +2107,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { ZI->getOperand(0)->getType() == Type::Int1Ty) return SelectInst::Create(ZI->getOperand(0), Context->getNullValue(I.getType()), - Context->getConstantIntAllOnesValue(I.getType())); + Context->getAllOnesValue(I.getType())); } if (isa<PHINode>(LHS)) @@ -2485,7 +2485,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (ConstantInt *C = dyn_cast<ConstantInt>(Op0)) { // Replace (-1 - A) with (~A)... if (C->isAllOnesValue()) - return BinaryOperator::CreateNot(Op1); + return BinaryOperator::CreateNot(*Context, Op1); // C - ~X == X + (1+C) Value *X = 0; @@ -2567,7 +2567,8 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { Value *OtherOp = Op1I->getOperand(Op1I->getOperand(0) == Op0); Value *NewNot = - InsertNewInstBefore(BinaryOperator::CreateNot(OtherOp, "B.not"), I); + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, + OtherOp, "B.not"), I); return BinaryOperator::CreateAnd(Op0, NewNot); } @@ -3219,7 +3220,7 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) { if (RHSI->getOpcode() == Instruction::Shl && isa<ConstantInt>(RHSI->getOperand(0))) { if (cast<ConstantInt>(RHSI->getOperand(0))->getValue().isPowerOf2()) { - Constant *N1 = Context->getConstantIntAllOnesValue(I.getType()); + Constant *N1 = Context->getAllOnesValue(I.getType()); Value *Add = InsertNewInstBefore(BinaryOperator::CreateAdd(RHSI, N1, "tmp"), I); return BinaryOperator::CreateAnd(Op0, Add); @@ -4128,7 +4129,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { Instruction *Or = BinaryOperator::CreateOr(Op0NotVal, Op1NotVal, I.getName()+".demorgan"); InsertNewInstBefore(Or, I); - return BinaryOperator::CreateNot(Or); + return BinaryOperator::CreateNot(*Context, Or); } { @@ -4174,7 +4175,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { std::swap(A, B); } if (A == Op0) { // A&(A^B) -> A & ~B - Instruction *NotB = BinaryOperator::CreateNot(B, "tmp"); + Instruction *NotB = BinaryOperator::CreateNot(*Context, B, "tmp"); InsertNewInstBefore(NotB, I); return BinaryOperator::CreateAnd(A, NotB); } @@ -4902,7 +4903,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) { Value *And = InsertNewInstBefore(BinaryOperator::CreateAnd(A, B, I.getName()+".demorgan"), I); - return BinaryOperator::CreateNot(And); + return BinaryOperator::CreateNot(*Context, And); } } @@ -5056,7 +5057,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (dyn_castNotVal(Op0I->getOperand(1), Context)) Op0I->swapOperands(); if (Value *Op0NotVal = dyn_castNotVal(Op0I->getOperand(0), Context)) { Instruction *NotY = - BinaryOperator::CreateNot(Op0I->getOperand(1), + BinaryOperator::CreateNot(*Context, Op0I->getOperand(1), Op0I->getOperand(1)->getName()+".not"); InsertNewInstBefore(NotY, I); if (Op0I->getOpcode() == Instruction::And) @@ -5202,7 +5203,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { std::swap(A, B); if (B == Op1) { // (A|B)^B == A & ~B Instruction *NotB = - InsertNewInstBefore(BinaryOperator::CreateNot(Op1, "tmp"), I); + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, + Op1, "tmp"), I); return BinaryOperator::CreateAnd(A, NotB); } } else if (match(Op0I, m_Xor(m_Specific(Op1), m_Value(B)), *Context)) { @@ -5216,7 +5218,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (B == Op1 && // (B&A)^A == ~B & A !isa<ConstantInt>(Op1)) { // Canonical form is (B&C)^C Instruction *N = - InsertNewInstBefore(BinaryOperator::CreateNot(A, "tmp"), I); + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, A, "tmp"), I); return BinaryOperator::CreateAnd(N, Op1); } } @@ -6006,7 +6008,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B) Instruction *Xor = BinaryOperator::CreateXor(Op0, Op1, I.getName()+"tmp"); InsertNewInstBefore(Xor, I); - return BinaryOperator::CreateNot(Xor); + return BinaryOperator::CreateNot(*Context, Xor); } case ICmpInst::ICMP_NE: // icmp eq i1 A, B -> A^B return BinaryOperator::CreateXor(Op0, Op1); @@ -6015,7 +6017,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { std::swap(Op0, Op1); // Change icmp ugt -> icmp ult // FALL THROUGH case ICmpInst::ICMP_ULT:{ // icmp ult i1 A, B -> ~A & B - Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(*Context, + Op0, I.getName()+"tmp"); InsertNewInstBefore(Not, I); return BinaryOperator::CreateAnd(Not, Op1); } @@ -6023,7 +6026,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { std::swap(Op0, Op1); // Change icmp sgt -> icmp slt // FALL THROUGH case ICmpInst::ICMP_SLT: { // icmp slt i1 A, B -> A & ~B - Instruction *Not = BinaryOperator::CreateNot(Op1, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(*Context, + Op1, I.getName()+"tmp"); InsertNewInstBefore(Not, I); return BinaryOperator::CreateAnd(Not, Op0); } @@ -6031,7 +6035,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { std::swap(Op0, Op1); // Change icmp uge -> icmp ule // FALL THROUGH case ICmpInst::ICMP_ULE: { // icmp ule i1 A, B -> ~A | B - Instruction *Not = BinaryOperator::CreateNot(Op0, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(*Context, + Op0, I.getName()+"tmp"); InsertNewInstBefore(Not, I); return BinaryOperator::CreateOr(Not, Op1); } @@ -6039,7 +6044,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { std::swap(Op0, Op1); // Change icmp sge -> icmp sle // FALL THROUGH case ICmpInst::ICMP_SLE: { // icmp sle i1 A, B -> A | ~B - Instruction *Not = BinaryOperator::CreateNot(Op1, I.getName()+"tmp"); + Instruction *Not = BinaryOperator::CreateNot(*Context, + Op1, I.getName()+"tmp"); InsertNewInstBefore(Not, I); return BinaryOperator::CreateOr(Not, Op0); } @@ -6168,7 +6174,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { // (x <u 2147483648) -> (x >s -1) -> true if sign bit clear if (CI->isMinValue(true)) return new ICmpInst(*Context, ICmpInst::ICMP_SGT, Op0, - Context->getConstantIntAllOnesValue(Op0->getType())); + Context->getAllOnesValue(Op0->getType())); } break; case ICmpInst::ICMP_UGT: @@ -7298,7 +7304,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) { if (isSignedExt) { // We're performing an unsigned comp with a sign extended value. // This is true if the input is >= 0. [aka >s -1] - Constant *NegOne = Context->getConstantIntAllOnesValue(SrcTy); + Constant *NegOne = Context->getAllOnesValue(SrcTy); Result = InsertNewInstBefore(new ICmpInst(*Context, ICmpInst::ICMP_SGT, LHSCIOp, NegOne, ICI.getName()), ICI); } else { @@ -7317,7 +7323,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) { "ICmp should be folded!"); if (Constant *CI = dyn_cast<Constant>(Result)) return ReplaceInstUsesWith(ICI, Context->getConstantExprNot(CI)); - return BinaryOperator::CreateNot(Result); + return BinaryOperator::CreateNot(*Context, Result); } Instruction *InstCombiner::visitShl(BinaryOperator &I) { @@ -8718,7 +8724,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) { // Canonicalize sign-extend from i1 to a select. if (Src->getType() == Type::Int1Ty) return SelectInst::Create(Src, - Context->getConstantIntAllOnesValue(CI.getType()), + Context->getAllOnesValue(CI.getType()), Context->getNullValue(CI.getType())); // See if the value being truncated is already sign extended. If so, just @@ -9373,7 +9379,7 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI, true/*SExt*/, "tmp", ICI); if (Pred == ICmpInst::ICMP_SGT) - In = InsertNewInstBefore(BinaryOperator::CreateNot(In, + In = InsertNewInstBefore(BinaryOperator::CreateNot(*Context, In, In->getName()+".not"), *ICI); return ReplaceInstUsesWith(SI, In); @@ -9438,7 +9444,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { } else { // Change: A = select B, false, C --> A = and !B, C Value *NotCond = - InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal, "not."+CondVal->getName()), SI); return BinaryOperator::CreateAnd(NotCond, FalseVal); } @@ -9449,7 +9455,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { } else { // Change: A = select B, C, true --> A = or !B, C Value *NotCond = - InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal, "not."+CondVal->getName()), SI); return BinaryOperator::CreateOr(NotCond, TrueVal); } @@ -9472,7 +9478,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { } else if (TrueValC->isZero() && FalseValC->getValue() == 1) { // select C, 0, 1 -> zext !C to int Value *NotCond = - InsertNewInstBefore(BinaryOperator::CreateNot(CondVal, + InsertNewInstBefore(BinaryOperator::CreateNot(*Context, CondVal, "not."+CondVal->getName()), SI); return CastInst::Create(Instruction::ZExt, NotCond, SI.getType()); } diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 24ac7bf..4116c66 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -1754,7 +1754,7 @@ namespace { switch (BO->getOpcode()) { case Instruction::And: { // "and i32 %a, %b" EQ -1 then %a EQ -1 and %b EQ -1 - ConstantInt *CI = ConstantInt::getAllOnesValue(Ty); + ConstantInt *CI = cast<ConstantInt>(Context->getAllOnesValue(Ty)); if (Canonical == CI) { add(CI, Op0, ICmpInst::ICMP_EQ, NewContext); add(CI, Op1, ICmpInst::ICMP_EQ, NewContext); @@ -1892,7 +1892,7 @@ namespace { Constant *Zero = Context->getNullValue(Ty); Constant *One = ConstantInt::get(Ty, 1); - ConstantInt *AllOnes = ConstantInt::getAllOnesValue(Ty); + ConstantInt *AllOnes = cast<ConstantInt>(Context->getAllOnesValue(Ty)); switch (Opcode) { default: break; diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 054e09d..6465fc1 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -201,7 +201,7 @@ static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) { static Instruction *LowerNegateToMultiply(Instruction *Neg, std::map<AssertingVH<>, unsigned> &ValueRankMap, LLVMContext *Context) { - Constant *Cst = Context->getConstantIntAllOnesValue(Neg->getType()); + Constant *Cst = Context->getAllOnesValue(Neg->getType()); Instruction *Res = BinaryOperator::CreateMul(Neg->getOperand(1), Cst, "",Neg); ValueRankMap.erase(Neg); @@ -626,7 +626,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, return Context->getNullValue(X->getType()); } else if (Opcode == Instruction::Or) { // ...|X|~X = -1 ++NumAnnihil; - return Context->getConstantIntAllOnesValue(X->getType()); + return Context->getAllOnesValue(X->getType()); } } } diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index e521be2..830895c 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -814,10 +814,10 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) { if (I.getOpcode() == Instruction::And) markConstant(IV, &I, Context->getNullValue(I.getType())); else if (const VectorType *PT = dyn_cast<VectorType>(I.getType())) - markConstant(IV, &I, Context->getConstantVectorAllOnesValue(PT)); + markConstant(IV, &I, Context->getAllOnesValue(PT)); else markConstant(IV, &I, - Context->getConstantIntAllOnesValue(I.getType())); + Context->getAllOnesValue(I.getType())); return; } else { if (I.getOpcode() == Instruction::And) { @@ -1388,9 +1388,9 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // undef | X -> -1. X could be -1. if (const VectorType *PTy = dyn_cast<VectorType>(ITy)) markForcedConstant(LV, I, - Context->getConstantVectorAllOnesValue(PTy)); + Context->getAllOnesValue(PTy)); else - markForcedConstant(LV, I, Context->getConstantIntAllOnesValue(ITy)); + markForcedConstant(LV, I, Context->getAllOnesValue(ITy)); return true; case Instruction::SDiv: diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp index a2f9a82..8a28ca2 100644 --- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp @@ -1225,7 +1225,7 @@ struct VISIBILITY_HIDDEN AbsOpt : public LibCallOptimization { // abs(x) -> x >s -1 ? x : -x Value *Op = CI->getOperand(1); Value *Pos = B.CreateICmpSGT(Op, - Context->getConstantIntAllOnesValue(Op->getType()), + Context->getAllOnesValue(Op->getType()), "ispos"); Value *Neg = B.CreateNeg(Op, "neg"); return B.CreateSelect(Pos, Op, Neg); |