diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -1610,7 +1610,7 @@ Value *CreateLogicalOr(Value *Cond1, Value *Cond2, const Twine &Name = "") { assert(Cond2->getType()->isIntOrIntVectorTy(1)); - return CreateSelect(Cond1, ConstantInt::getAllOnesValue(Cond2->getType()), + return CreateSelect(Cond1, ConstantInt::getAllOnes(Cond2->getType()), Cond2, Name); } @@ -1676,7 +1676,7 @@ } Value *CreateNot(Value *V, const Twine &Name = "") { - return CreateXor(V, Constant::getAllOnesValue(V->getType()), Name); + return CreateXor(V, ConstantInt::getAllOnes(V->getType()), Name); } Value *CreateUnOp(Instruction::UnaryOps Opc, @@ -2452,7 +2452,7 @@ /// Return a boolean value testing if \p Arg > -1. Value *CreateIsNotNeg(Value *Arg, const Twine &Name = "") { - return CreateICmpSGT(Arg, ConstantInt::getAllOnesValue(Arg->getType()), + return CreateICmpSGT(Arg, ConstantInt::getAllOnes(Arg->getType()), Name); } diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2064,7 +2064,7 @@ // (X + C) ^ (~C - X) --> (X + C) ^ ~(X + C) --> -1 Type *Ty = Op0->getType(); return Opcode == Instruction::And ? ConstantInt::getNullValue(Ty) - : ConstantInt::getAllOnesValue(Ty); + : ConstantInt::getAllOnes(Ty); } } return nullptr; @@ -2286,11 +2286,11 @@ // X | ~X --> -1 if (match(Y, m_Not(m_Specific(X)))) - return ConstantInt::getAllOnesValue(Ty); + return ConstantInt::getAllOnes(Ty); // X | ~(X & ?) = -1 if (match(Y, m_Not(m_c_And(m_Specific(X), m_Value())))) - return ConstantInt::getAllOnesValue(Ty); + return ConstantInt::getAllOnes(Ty); // X | (X & ?) --> X if (match(Y, m_c_And(m_Specific(X), m_Value()))) @@ -2308,7 +2308,7 @@ // ~(A ^ B) | (B | A) --> -1 if (match(X, m_Not(m_Xor(m_Value(A), m_Value(B)))) && match(Y, m_c_Or(m_Specific(A), m_Specific(B)))) - return ConstantInt::getAllOnesValue(Ty); + return ConstantInt::getAllOnes(Ty); // (A & ~B) | (A ^ B) --> A ^ B // (~B & A) | (A ^ B) --> A ^ B @@ -2332,7 +2332,7 @@ // (B | ~A) | (B ^ A) --> -1 if (match(X, m_c_Or(m_Not(m_Value(A)), m_Value(B))) && match(Y, m_c_Xor(m_Specific(A), m_Specific(B)))) - return ConstantInt::getAllOnesValue(Ty); + return ConstantInt::getAllOnes(Ty); // (~A & B) | ~(A | B) --> ~A // (~A & B) | ~(B | A) --> ~A @@ -2386,7 +2386,7 @@ // X | -1 = -1 // Do not return Op1 because it may contain undef elements if it's a vector. if (Q.isUndefValue(Op1) || match(Op1, m_AllOnes())) - return Constant::getAllOnesValue(Op0->getType()); + return ConstantInt::getAllOnes(Op0->getType()); // X | X = X // X | 0 = X @@ -2414,7 +2414,7 @@ if ((match(X, m_Sub(m_APInt(C), m_Specific(Y))) || match(Y, m_Sub(m_APInt(C), m_Specific(X)))) && C->ule(X->getType()->getScalarSizeInBits())) { - return ConstantInt::getAllOnesValue(X->getType()); + return ConstantInt::getAllOnes(X->getType()); } } @@ -2568,7 +2568,7 @@ // A ^ ~A = ~A ^ A = -1 if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) - return Constant::getAllOnesValue(Op0->getType()); + return ConstantInt::getAllOnes(Op0->getType()); auto foldAndOrNot = [](Value *X, Value *Y) -> Value * { Value *A, *B; @@ -6469,7 +6469,7 @@ // Rotating -1 by anything is -1. if (match(Op0, m_AllOnes()) && match(Op1, m_AllOnes())) - return ConstantInt::getAllOnesValue(F->getReturnType()); + return ConstantInt::getAllOnes(F->getReturnType()); return nullptr; } diff --git a/llvm/lib/CodeGen/ExpandReductions.cpp b/llvm/lib/CodeGen/ExpandReductions.cpp --- a/llvm/lib/CodeGen/ExpandReductions.cpp +++ b/llvm/lib/CodeGen/ExpandReductions.cpp @@ -152,7 +152,7 @@ Rdx = Builder.CreateBitCast(Vec, Builder.getIntNTy(NumElts)); if (ID == Intrinsic::vector_reduce_and) { Rdx = Builder.CreateICmpEQ( - Rdx, ConstantInt::getAllOnesValue(Rdx->getType())); + Rdx, ConstantInt::getAllOnes(Rdx->getType())); } else { assert(ID == Intrinsic::vector_reduce_or && "Expected or reduction."); Rdx = Builder.CreateIsNotNull(Rdx); diff --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp --- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp +++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp @@ -287,7 +287,7 @@ return ConstantInt::get(EltTy, 1, /*IsSigned*/ false); case Intrinsic::vp_reduce_and: case Intrinsic::vp_reduce_umin: - return ConstantInt::getAllOnesValue(EltTy); + return ConstantInt::getAllOnes(EltTy); case Intrinsic::vp_reduce_smin: return ConstantInt::get(EltTy->getContext(), APInt::getSignedMaxValue(EltBits)); diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -2380,7 +2380,7 @@ Rep = Builder.CreateBitCast(Rep, Builder.getInt16Ty()); Value *C; if (Name[14] == 'c') - C = ConstantInt::getAllOnesValue(Builder.getInt16Ty()); + C = ConstantInt::getAllOnes(Builder.getInt16Ty()); else C = ConstantInt::getNullValue(Builder.getInt16Ty()); Rep = Builder.CreateICmpEQ(Rep, C); diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp --- a/llvm/lib/IR/VectorBuilder.cpp +++ b/llvm/lib/IR/VectorBuilder.cpp @@ -34,7 +34,7 @@ Value *VectorBuilder::getAllTrueMask() { auto *BoolTy = Builder.getInt1Ty(); auto *MaskTy = VectorType::get(BoolTy, StaticVectorLength); - return ConstantInt::getAllOnesValue(MaskTy); + return ConstantInt::getAllOnes(MaskTy); } Value &VectorBuilder::requestMask() { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1509,7 +1509,7 @@ if (match(&I, m_Add(m_OneUse(m_c_And(m_Value(A), m_OneUse(m_Neg(m_Deferred(A))))), m_AllOnes()))) { - Constant *AllOnes = ConstantInt::getAllOnesValue(RHS->getType()); + Constant *AllOnes = ConstantInt::getAllOnes(RHS->getType()); Value *Dec = Builder.CreateAdd(A, AllOnes); Value *Not = Builder.CreateXor(A, AllOnes); return BinaryOperator::CreateAnd(Dec, Not); @@ -1526,7 +1526,7 @@ Type *Ty = I.getType(); Constant *NewMulC = ConstantInt::get(Ty, 1 - *C1); Value *NewMul = Builder.CreateMul(A, NewMulC); - return BinaryOperator::CreateAdd(NewMul, ConstantInt::getAllOnesValue(Ty)); + return BinaryOperator::CreateAdd(NewMul, ConstantInt::getAllOnes(Ty)); } // (A * -2**C) + B --> B - (A << C) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -3369,10 +3369,10 @@ // canonicalization? if (match(Op0, m_OneUse(m_SExt(m_Value(A)))) && A->getType()->isIntOrIntVectorTy(1)) - return SelectInst::Create(A, ConstantInt::getAllOnesValue(Ty), Op1); + return SelectInst::Create(A, ConstantInt::getAllOnes(Ty), Op1); if (match(Op1, m_OneUse(m_SExt(m_Value(A)))) && A->getType()->isIntOrIntVectorTy(1)) - return SelectInst::Create(A, ConstantInt::getAllOnesValue(Ty), Op0); + return SelectInst::Create(A, ConstantInt::getAllOnes(Ty), Op0); // Note: If we've gotten to the point of visiting the outer OR, then the // inner one couldn't be simplified. If it was a constant, then it won't @@ -3409,7 +3409,7 @@ m_SpecificInt(Ty->getScalarSizeInBits() - 1))), m_Deferred(X)))) { Value *NewICmpInst = Builder.CreateICmpSGT(X, Y); - Value *AllOnes = ConstantInt::getAllOnesValue(Ty); + Value *AllOnes = ConstantInt::getAllOnes(Ty); return SelectInst::Create(NewICmpInst, AllOnes, X); } } @@ -3703,7 +3703,7 @@ if (D->hasOneUse() && match(M, m_Constant(C))) { // Propagating undef is unsafe. Clamp undef elements to -1. Type *EltTy = C->getType()->getScalarType(); - C = Constant::replaceUndefsWith(C, ConstantInt::getAllOnesValue(EltTy)); + C = Constant::replaceUndefsWith(C, ConstantInt::getAllOnes(EltTy)); // Unfold. Value *LHS = Builder.CreateAnd(X, C); Value *NotC = Builder.CreateNot(C); @@ -3974,7 +3974,7 @@ // ~((-X) | Y) --> (X - 1) & (~Y) if (match(NotVal, m_OneUse(m_c_Or(m_OneUse(m_Neg(m_Value(X))), m_Value(Y))))) { - Value *DecX = Builder.CreateAdd(X, ConstantInt::getAllOnesValue(Ty)); + Value *DecX = Builder.CreateAdd(X, ConstantInt::getAllOnes(Ty)); Value *NotY = Builder.CreateNot(Y); return BinaryOperator::CreateAnd(DecX, NotY); } @@ -4003,7 +4003,7 @@ // We matched a negative constant, so propagating undef is unsafe. // Clamp undef elements to -1. Type *EltTy = Ty->getScalarType(); - C = Constant::replaceUndefsWith(C, ConstantInt::getAllOnesValue(EltTy)); + C = Constant::replaceUndefsWith(C, ConstantInt::getAllOnes(EltTy)); return BinaryOperator::CreateLShr(ConstantExpr::getNot(C), Y); } diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2856,7 +2856,7 @@ Vect, Builder.getIntNTy(FTy->getNumElements())); if (IID == Intrinsic::vector_reduce_and) { Res = Builder.CreateICmpEQ( - Res, ConstantInt::getAllOnesValue(Res->getType())); + Res, ConstantInt::getAllOnes(Res->getType())); } else { assert(IID == Intrinsic::vector_reduce_or && "Expected or reduction."); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1421,7 +1421,7 @@ // If the icmp tests for a known zero bit we can constant fold it. if (!Op1C->isZero() && Op1C->getValue() != KnownZeroMask) { Value *V = Pred == ICmpInst::ICMP_NE ? - ConstantInt::getAllOnesValue(Sext.getType()) : + ConstantInt::getAllOnes(Sext.getType()) : ConstantInt::getNullValue(Sext.getType()); return replaceInstUsesWith(Sext, V); } @@ -1438,7 +1438,7 @@ // At this point "In" is either 1 or 0. Subtract 1 to turn // {1, 0} -> {0, -1}. In = Builder.CreateAdd(In, - ConstantInt::getAllOnesValue(In->getType()), + ConstantInt::getAllOnes(In->getType()), "sext"); } else { // sext ((x & 2^n) != 0) -> (x << bitwidth-n) a>> bitwidth-1 diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1506,7 +1506,7 @@ return TrueIfSigned ? new ICmpInst(ICmpInst::ICMP_SLT, ShOp, ConstantInt::getNullValue(SrcTy)) : new ICmpInst(ICmpInst::ICMP_SGT, ShOp, - ConstantInt::getAllOnesValue(SrcTy)); + ConstantInt::getAllOnes(SrcTy)); } return nullptr; @@ -1539,7 +1539,7 @@ // Emit the opposite comparison. if (TrueIfSigned) return new ICmpInst(ICmpInst::ICMP_SGT, X, - ConstantInt::getAllOnesValue(X->getType())); + ConstantInt::getAllOnes(X->getType())); else return new ICmpInst(ICmpInst::ICMP_SLT, X, ConstantInt::getNullValue(X->getType())); @@ -2356,7 +2356,7 @@ } if (Pred == CmpInst::ICMP_ULT) { return new ICmpInst(CmpInst::ICMP_SGT, X, - ConstantInt::getAllOnesValue(ShrTy)); + ConstantInt::getAllOnes(ShrTy)); } } } else { @@ -3007,7 +3007,7 @@ // icmp sgt (bitcast (sitofp X)), -1 --> icmp sgt X, -1 if (Pred == ICmpInst::ICMP_SGT && match(Op1, m_AllOnes())) return new ICmpInst(Pred, X, - ConstantInt::getAllOnesValue(X->getType())); + ConstantInt::getAllOnes(X->getType())); } // Zero-equality checks are preserved through unsigned floating-point casts: @@ -3042,7 +3042,7 @@ ConstantInt::getNullValue(NewType)); else return new ICmpInst(ICmpInst::ICMP_SGT, NewBitcast, - ConstantInt::getAllOnesValue(NewType)); + ConstantInt::getAllOnes(NewType)); } } } @@ -3488,11 +3488,11 @@ Value *X = II->getArgOperand(0); if (C == BitWidth - 1 && Pred == ICmpInst::ICMP_UGT) return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_EQ, X, - ConstantInt::getAllOnesValue(Ty)); + ConstantInt::getAllOnes(Ty)); // (ctpop X < BitWidth) --> X != -1 if (C == BitWidth && Pred == ICmpInst::ICMP_ULT) return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_NE, X, - ConstantInt::getAllOnesValue(Ty)); + ConstantInt::getAllOnes(Ty)); break; } case Intrinsic::ctlz: { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -1280,7 +1280,7 @@ } // Op0 / (sext i1 X) --> zext (Op0 == -1) (if X is 0, the div is undefined) if (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)) { - Value *Cmp = Builder.CreateICmpEQ(Op0, ConstantInt::getAllOnesValue(Ty)); + Value *Cmp = Builder.CreateICmpEQ(Op0, ConstantInt::getAllOnes(Ty)); return CastInst::CreateZExtOrBitCast(Cmp, Ty); } @@ -1413,7 +1413,7 @@ m_Deferred(X)))) { Value *Cond = Builder.CreateIsNotNeg(X); return SelectInst::Create(Cond, ConstantInt::get(Ty, 1), - ConstantInt::getAllOnesValue(Ty)); + ConstantInt::getAllOnes(Ty)); } KnownBits KnownDividend = computeKnownBits(Op0, 0, &I); @@ -1859,7 +1859,7 @@ // urem Op0, (sext i1 X) --> (Op0 == -1) ? 0 : Op0 Value *X; if (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)) { - Value *Cmp = Builder.CreateICmpEQ(Op0, ConstantInt::getAllOnesValue(Ty)); + Value *Cmp = Builder.CreateICmpEQ(Op0, ConstantInt::getAllOnes(Ty)); return SelectInst::Create(Cmp, ConstantInt::getNullValue(Ty), Op0); } diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -1126,7 +1126,7 @@ // Valid for any type of right-shift. Value *X; if (match(Op0, m_OneUse(m_Shr(m_Value(X), m_Specific(Op1))))) { - Constant *AllOnes = ConstantInt::getAllOnesValue(Ty); + Constant *AllOnes = ConstantInt::getAllOnes(Ty); Value *Mask = Builder.CreateShl(AllOnes, Op1); return BinaryOperator::CreateAnd(Mask, X); } @@ -1423,7 +1423,7 @@ // Transform (x << y) >> y to x & (-1 >> y) if (match(Op0, m_OneUse(m_Shl(m_Value(X), m_Specific(Op1))))) { - Constant *AllOnes = ConstantInt::getAllOnesValue(Ty); + Constant *AllOnes = ConstantInt::getAllOnes(Ty); Value *Mask = Builder.CreateLShr(AllOnes, Op1); return BinaryOperator::CreateAnd(Mask, X); } diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -308,7 +308,7 @@ if (match(I->getOperand(1), m_APInt(C)) && !C->isAllOnes()) { if ((*C | ~DemandedMask).isAllOnes()) { // Force bits to 1 to create a 'not' op. - I->setOperand(1, ConstantInt::getAllOnesValue(VTy)); + I->setOperand(1, ConstantInt::getAllOnes(VTy)); return I; } // If we can't turn this into a 'not', try to shrink the constant. diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -2054,7 +2054,7 @@ case Instruction::Sub: // sub 0, X --> mul X, -1 if (match(BO0, m_ZeroInt())) - return {Instruction::Mul, BO1, ConstantInt::getAllOnesValue(Ty)}; + return {Instruction::Mul, BO1, ConstantInt::getAllOnes(Ty)}; break; default: break; diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1019,7 +1019,7 @@ return nullptr; // bo (sext i1 X), C --> select X, (bo -1, C), (bo 0, C) - Constant *Ones = ConstantInt::getAllOnesValue(BO.getType()); + Constant *Ones = ConstantInt::getAllOnes(BO.getType()); Constant *Zero = ConstantInt::getNullValue(BO.getType()); Value *TVal = Builder.CreateBinOp(BO.getOpcode(), Ones, C); Value *FVal = Builder.CreateBinOp(BO.getOpcode(), Zero, C); @@ -3978,7 +3978,7 @@ for (const auto *U : I.users()) { Constant *C = NullValue; if (match(U, m_Or(m_Value(), m_Value()))) - C = ConstantInt::getAllOnesValue(Ty); + C = ConstantInt::getAllOnes(Ty); else if (match(U, m_Select(m_Specific(&I), m_Constant(), m_Value()))) C = ConstantInt::getTrue(Ty); diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -455,7 +455,7 @@ SmallVector MyGood; SmallVector MyBad; DoInitialMatch(NewMul, L, MyGood, MyBad, SE); - const SCEV *NegOne = SE.getSCEV(ConstantInt::getAllOnesValue( + const SCEV *NegOne = SE.getSCEV(ConstantInt::getAllOnes( SE.getEffectiveSCEVType(NewMul->getType()))); for (const SCEV *S : MyGood) Good.push_back(SE.getMulExpr(NegOne, S)); diff --git a/llvm/tools/llvm-stress/llvm-stress.cpp b/llvm/tools/llvm-stress/llvm-stress.cpp --- a/llvm/tools/llvm-stress/llvm-stress.cpp +++ b/llvm/tools/llvm-stress/llvm-stress.cpp @@ -217,7 +217,7 @@ Constant *getRandomConstant(Type *Tp) { if (Tp->isIntegerTy()) { if (getRandom() & 1) - return ConstantInt::getAllOnesValue(Tp); + return ConstantInt::getAllOnes(Tp); return ConstantInt::getNullValue(Tp); } else if (Tp->isFloatingPointTy()) { if (getRandom() & 1) @@ -239,7 +239,7 @@ // If the requested type was not found, generate a constant value. if (Tp->isIntegerTy()) { if (getRandom() & 1) - return ConstantInt::getAllOnesValue(Tp); + return ConstantInt::getAllOnes(Tp); return ConstantInt::getNullValue(Tp); } else if (Tp->isFloatingPointTy()) { if (getRandom() & 1)