From 4fc56d70aadea9df88e7bf408e2e203dc79ff8e6 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Wed, 19 Aug 2020 17:13:28 +0000 Subject: [PATCH] Revert "[NFC][llvm] Make the contructors of `ElementCount` private." This reverts commit 264afb9e6aebc98c353644dd0700bec808501cab. (and dependent 6b742cc48 and fc53bd610f) MLIR/Flang are broken. --- clang/lib/AST/ASTContext.cpp | 4 +-- llvm/include/llvm/Analysis/VectorUtils.h | 5 ++-- llvm/include/llvm/IR/DerivedTypes.h | 5 ++-- llvm/include/llvm/IR/Intrinsics.h | 7 ++--- llvm/include/llvm/Support/MachineValueType.h | 2 +- llvm/include/llvm/Support/TypeSize.h | 33 ++++++---------------- llvm/lib/Analysis/VFABIDemangling.cpp | 2 +- llvm/lib/AsmParser/LLParser.cpp | 4 +-- .../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 8 +++--- llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 +- llvm/lib/CodeGen/ValueTypes.cpp | 3 +- llvm/lib/IR/ConstantFold.cpp | 3 +- llvm/lib/IR/Constants.cpp | 4 +-- llvm/lib/IR/IRBuilder.cpp | 2 +- llvm/lib/IR/Instructions.cpp | 8 +++--- llvm/lib/IR/Type.cpp | 4 +-- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 3 +- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 17 ++++++----- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 15 +++++----- llvm/unittests/Analysis/VectorUtilsTest.cpp | 5 ++-- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp | 13 ++++----- llvm/unittests/FuzzMutate/OperationsTest.cpp | 4 +-- llvm/unittests/IR/ConstantsTest.cpp | 4 +-- llvm/unittests/IR/PatternMatch.cpp | 4 +-- llvm/unittests/IR/VectorTypesTest.cpp | 29 +++++++++---------- llvm/unittests/IR/VerifierTest.cpp | 2 +- 26 files changed, 83 insertions(+), 109 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a9cab40..c51629e 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3714,11 +3714,11 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType, ASTContext::BuiltinVectorTypeInfo ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const { #define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \ - {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount::getScalable(ELTS), \ + {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true), \ NUMVECTORS}; #define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \ - {ELTTY, llvm::ElementCount::getScalable(ELTS), NUMVECTORS}; + {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS}; switch (Ty->getKind()) { default: diff --git a/llvm/include/llvm/Analysis/VectorUtils.h b/llvm/include/llvm/Analysis/VectorUtils.h index f77048d..a860652 100644 --- a/llvm/include/llvm/Analysis/VectorUtils.h +++ b/llvm/include/llvm/Analysis/VectorUtils.h @@ -99,8 +99,7 @@ struct VFShape { // Retrieve the VFShape that can be used to map a (scalar) function to itself, // with VF = 1. static VFShape getScalarShape(const CallInst &CI) { - return VFShape::get(CI, ElementCount::getFixed(1), - /*HasGlobalPredicate*/ false); + return VFShape::get(CI, /*EC*/ {1, false}, /*HasGlobalPredicate*/ false); } // Retrieve the basic vectorization shape of the function, where all @@ -306,7 +305,7 @@ typedef unsigned ID; inline Type *ToVectorTy(Type *Scalar, unsigned VF, bool isScalable = false) { if (Scalar->isVoidTy() || VF == 1) return Scalar; - return VectorType::get(Scalar, ElementCount::get(VF, isScalable)); + return VectorType::get(Scalar, {VF, isScalable}); } /// Identify if the intrinsic is trivially vectorizable. diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h index 1837f68..8438099 100644 --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -446,8 +446,7 @@ public: static VectorType *get(Type *ElementType, unsigned NumElements, bool Scalable) { - return VectorType::get(ElementType, - ElementCount::get(NumElements, Scalable)); + return VectorType::get(ElementType, {NumElements, Scalable}); } static VectorType *get(Type *ElementType, const VectorType *Other) { @@ -641,7 +640,7 @@ public: }; inline ElementCount VectorType::getElementCount() const { - return ElementCount::get(ElementQuantity, isa(this)); + return ElementCount(ElementQuantity, isa(this)); } /// Class to represent pointers. diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h index 3fc7c5a..a9e6525 100644 --- a/llvm/include/llvm/IR/Intrinsics.h +++ b/llvm/include/llvm/IR/Intrinsics.h @@ -134,9 +134,7 @@ namespace Intrinsic { unsigned Pointer_AddressSpace; unsigned Struct_NumElements; unsigned Argument_Info; - // There is no default constructor in `ElementCount`, so we need - // to explicitly initialize this field with a value. - ElementCount Vector_Width = ElementCount::getFixed(0); + ElementCount Vector_Width; }; enum ArgKind { @@ -192,7 +190,8 @@ namespace Intrinsic { static IITDescriptor getVector(unsigned Width, bool IsScalable) { IITDescriptor Result; Result.Kind = Vector; - Result.Vector_Width = ElementCount::get(Width, IsScalable); + Result.Vector_Width.Min = Width; + Result.Vector_Width.Scalable = IsScalable; return Result; } }; diff --git a/llvm/include/llvm/Support/MachineValueType.h b/llvm/include/llvm/Support/MachineValueType.h index 172d4fd..3bb8220 100644 --- a/llvm/include/llvm/Support/MachineValueType.h +++ b/llvm/include/llvm/Support/MachineValueType.h @@ -737,7 +737,7 @@ namespace llvm { } ElementCount getVectorElementCount() const { - return ElementCount::get(getVectorNumElements(), isScalableVector()); + return { getVectorNumElements(), isScalableVector() }; } /// Given a vector type, return the minimum number of elements it contains. diff --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h index a95d388..d5a3614 100644 --- a/llvm/include/llvm/Support/TypeSize.h +++ b/llvm/include/llvm/Support/TypeSize.h @@ -26,23 +26,16 @@ namespace llvm { template struct DenseMapInfo; class ElementCount { -private: - /// Prevent code from using initializer-list contructors like - /// ElementCount EC = {, }. The static `get*` - /// methods below are preferred, as users should always make a - /// conscious choice on the type of `ElementCount` they are - /// requesting. - ElementCount(unsigned Min, bool Scalable) : Min(Min), Scalable(Scalable) {} - public: - /// No default constructor. Users should use one of the `get*` - /// static methods below, as they should always make a conscious - /// choice on the type of `ElementCount` they are requesting. - ElementCount() = delete; unsigned Min; // Minimum number of vector elements. bool Scalable; // If true, NumElements is a multiple of 'Min' determined // at runtime rather than compile time. + ElementCount() = default; + + ElementCount(unsigned Min, bool Scalable) + : Min(Min), Scalable(Scalable) {} + ElementCount operator*(unsigned RHS) { return { Min * RHS, Scalable }; } @@ -61,13 +54,7 @@ public: bool operator!=(unsigned RHS) const { return !(*this == RHS); } ElementCount NextPowerOf2() const { - return {(unsigned)llvm::NextPowerOf2(Min), Scalable}; - } - - static ElementCount getFixed(unsigned Min) { return {Min, false}; } - static ElementCount getScalable(unsigned Min) { return {Min, true}; } - static ElementCount get(unsigned Min, bool Scalable) { - return {Min, Scalable}; + return ElementCount(llvm::NextPowerOf2(Min), Scalable); } }; @@ -292,12 +279,8 @@ inline TypeSize alignTo(TypeSize Size, uint64_t Align) { } template <> struct DenseMapInfo { - static inline ElementCount getEmptyKey() { - return ElementCount::getScalable(~0U); - } - static inline ElementCount getTombstoneKey() { - return ElementCount::getFixed(~0U - 1); - } + static inline ElementCount getEmptyKey() { return {~0U, true}; } + static inline ElementCount getTombstoneKey() { return {~0U - 1, false}; } static unsigned getHashValue(const ElementCount& EltCnt) { if (EltCnt.Scalable) return (EltCnt.Min * 37U) - 1U; diff --git a/llvm/lib/Analysis/VFABIDemangling.cpp b/llvm/lib/Analysis/VFABIDemangling.cpp index 56155b2..0192a21 100644 --- a/llvm/lib/Analysis/VFABIDemangling.cpp +++ b/llvm/lib/Analysis/VFABIDemangling.cpp @@ -310,7 +310,7 @@ ElementCount getECFromSignature(FunctionType *Signature) { if (auto *VTy = dyn_cast(Ty)) return VTy->getElementCount(); - return ElementCount::getFixed(/*Min=*/1); + return ElementCount(/*Min=*/1, /*Scalable=*/false); } } // namespace diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index fec10b8..06e5709 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -7395,7 +7395,7 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { // All vector parameters should have the same vector width. ElementCount GEPWidth = BaseType->isVectorTy() ? cast(BaseType)->getElementCount() - : ElementCount::getFixed(0); + : ElementCount(0, false); while (EatIfPresent(lltok::comma)) { if (Lex.getKind() == lltok::MetadataVar) { @@ -7408,7 +7408,7 @@ int LLParser::ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) { if (auto *ValVTy = dyn_cast(Val->getType())) { ElementCount ValNumEl = ValVTy->getElementCount(); - if (GEPWidth != ElementCount::getFixed(0) && GEPWidth != ValNumEl) + if (GEPWidth != ElementCount(0, false) && GEPWidth != ValNumEl) return Error(EltLoc, "getelementptr vector index has a wrong number of elements"); GEPWidth = ValNumEl; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 80a2db2..fd1859a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -729,15 +729,15 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL, assert(IntermediateVT.isScalableVector() == ValueVT.isScalableVector() && "Mixing scalable and fixed vectors when copying in parts"); - Optional DestEltCnt; + ElementCount DestEltCnt; if (IntermediateVT.isVector()) DestEltCnt = IntermediateVT.getVectorElementCount() * NumIntermediates; else - DestEltCnt = ElementCount::getFixed(NumIntermediates); + DestEltCnt = ElementCount(NumIntermediates, false); EVT BuiltVectorTy = EVT::getVectorVT( - *DAG.getContext(), IntermediateVT.getScalarType(), DestEltCnt.getValue()); + *DAG.getContext(), IntermediateVT.getScalarType(), DestEltCnt); if (ValueVT != BuiltVectorTy) { if (SDValue Widened = widenVectorToPartType(DAG, Val, DL, BuiltVectorTy)) Val = Widened; @@ -3746,7 +3746,7 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) { bool IsVectorGEP = I.getType()->isVectorTy(); ElementCount VectorElementCount = IsVectorGEP ? cast(I.getType())->getElementCount() - : ElementCount::getFixed(0); + : ElementCount(0, false); if (IsVectorGEP && !N.getValueType().isVector()) { LLVMContext &Context = *DAG.getContext(); diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 868302a..63e55c9 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -866,7 +866,7 @@ TargetLoweringBase::getTypeConversion(LLVMContext &Context, EVT VT) const { if (NumElts == 1) return LegalizeKind(TypeScalarizeVector, EltVT); - if (VT.getVectorElementCount() == ElementCount::getScalable(1)) + if (VT.getVectorElementCount() == ElementCount(1, true)) report_fatal_error("Cannot legalize this vector"); // Try to widen vector elements until the element type is a power of two and diff --git a/llvm/lib/CodeGen/ValueTypes.cpp b/llvm/lib/CodeGen/ValueTypes.cpp index c397451..57e26e8c 100644 --- a/llvm/lib/CodeGen/ValueTypes.cpp +++ b/llvm/lib/CodeGen/ValueTypes.cpp @@ -49,7 +49,8 @@ EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, ElementCount EC) { EVT ResultVT; - ResultVT.LLVMTy = VectorType::get(VT.getTypeForEVT(Context), EC); + ResultVT.LLVMTy = + VectorType::get(VT.getTypeForEVT(Context), {EC.Min, EC.Scalable}); assert(ResultVT.isExtended() && "Type is not extended!"); return ResultVT; } diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index e5c4250..2d3afca 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -919,8 +919,7 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef Mask) { auto *V1VTy = cast(V1->getType()); unsigned MaskNumElts = Mask.size(); - auto MaskEltCount = - ElementCount::get(MaskNumElts, isa(V1VTy)); + ElementCount MaskEltCount = {MaskNumElts, isa(V1VTy)}; Type *EltTy = V1VTy->getElementType(); // Undefined shuffle mask -> undefined value. diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index b252ef7..cbbcca2 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2245,7 +2245,7 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, unsigned AS = C->getType()->getPointerAddressSpace(); Type *ReqTy = DestTy->getPointerTo(AS); - auto EltCount = ElementCount::getFixed(0); + ElementCount EltCount = {0, false}; if (VectorType *VecTy = dyn_cast(C->getType())) EltCount = VecTy->getElementCount(); else @@ -2938,7 +2938,7 @@ Constant *ConstantDataVector::getSplat(unsigned NumElts, Constant *V) { return getFP(V->getType(), Elts); } } - return ConstantVector::getSplat(ElementCount::getFixed(NumElts), V); + return ConstantVector::getSplat({NumElts, false}, V); } diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 1de25c2..f059f80 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -997,7 +997,7 @@ Value *IRBuilderBase::CreateStripInvariantGroup(Value *Ptr) { Value *IRBuilderBase::CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name) { - auto EC = ElementCount::getFixed(NumElts); + ElementCount EC(NumElts, false); return CreateVectorSplat(EC, V, Name); } diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 7a3fbc36..2f17a0d 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3330,9 +3330,9 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, Type *DstTy) { // scalar types means that checking that vector lengths match also checks that // scalars are not being converted to vectors or vectors to scalars). ElementCount SrcEC = SrcIsVec ? cast(SrcTy)->getElementCount() - : ElementCount::getFixed(0); + : ElementCount(0, false); ElementCount DstEC = DstIsVec ? cast(DstTy)->getElementCount() - : ElementCount::getFixed(0); + : ElementCount(0, false); // Switch on the opcode provided switch (op) { @@ -3390,9 +3390,9 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, Type *DstTy) { if (SrcIsVec && DstIsVec) return SrcEC == DstEC; if (SrcIsVec) - return SrcEC == ElementCount::getFixed(1); + return SrcEC == ElementCount(1, false); if (DstIsVec) - return DstEC == ElementCount::getFixed(1); + return DstEC == ElementCount(1, false); return true; } diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 1cf0d13..d869a6e 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -619,7 +619,7 @@ FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) { "be an integer, floating point, or " "pointer type."); - auto EC = ElementCount::getFixed(NumElts); + ElementCount EC(NumElts, false); LLVMContextImpl *pImpl = ElementType->getContext().pImpl; VectorType *&Entry = ElementType->getContext() @@ -641,7 +641,7 @@ ScalableVectorType *ScalableVectorType::get(Type *ElementType, "be an integer, floating point, or " "pointer type."); - auto EC = ElementCount::getScalable(MinNumElts); + ElementCount EC(MinNumElts, true); LLVMContextImpl *pImpl = ElementType->getContext().pImpl; VectorType *&Entry = ElementType->getContext() diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 6c76243..b379474 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -11985,8 +11985,7 @@ static SDValue LowerSVEIntrinsicEXT(SDNode *N, SelectionDAG &DAG) { unsigned ElemSize = VT.getVectorElementType().getSizeInBits() / 8; unsigned ByteSize = VT.getSizeInBits().getKnownMinSize() / 8; - EVT ByteVT = - EVT::getVectorVT(Ctx, MVT::i8, ElementCount::getScalable(ByteSize)); + EVT ByteVT = EVT::getVectorVT(Ctx, MVT::i8, { ByteSize, true }); // Convert everything to the domain of EXT (i.e bytes). SDValue Op0 = DAG.getNode(ISD::BITCAST, dl, ByteVT, N->getOperand(1)); diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 90a8d47..ee82899 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1804,10 +1804,10 @@ void InnerLoopVectorizer::createVectorIntOrFpInductionPHI( // FIXME: If the step is non-constant, we create the vector splat with // IRBuilder. IRBuilder can constant-fold the multiply, but it doesn't // handle a constant vector splat. - Value *SplatVF = isa(Mul) - ? ConstantVector::getSplat(ElementCount::getFixed(VF), - cast(Mul)) - : Builder.CreateVectorSplat(VF, Mul); + Value *SplatVF = + isa(Mul) + ? ConstantVector::getSplat({VF, false}, cast(Mul)) + : Builder.CreateVectorSplat(VF, Mul); Builder.restoreIP(CurrIP); // We may need to add the step a number of times, depending on the unroll @@ -3399,8 +3399,7 @@ unsigned LoopVectorizationCostModel::getVectorCallCost(CallInst *CI, // If we can't emit a vector call for this function, then the currently found // cost is the cost we need to return. NeedToScalarize = true; - VFShape Shape = - VFShape::get(*CI, ElementCount::getFixed(VF), false /*HasGlobalPred*/); + VFShape Shape = VFShape::get(*CI, {VF, false}, false /*HasGlobalPred*/); Function *VecFunc = VFDatabase(*CI).getVectorizedFunction(Shape); if (!TLI || CI->isNoBuiltin() || !VecFunc) @@ -3861,7 +3860,7 @@ void InnerLoopVectorizer::fixReduction(PHINode *Phi) { // incoming scalar reduction. VectorStart = ReductionStartValue; } else { - Identity = ConstantVector::getSplat(ElementCount::getFixed(VF), Iden); + Identity = ConstantVector::getSplat({VF, false}, Iden); // This vector is the Identity vector where the first element is the // incoming scalar reduction. @@ -4542,8 +4541,8 @@ void InnerLoopVectorizer::widenCallInstruction(CallInst &I, VPUser &ArgOperands, assert(VectorF && "Can't retrieve vector intrinsic."); } else { // Use vector version of the function call. - const VFShape Shape = VFShape::get(*CI, ElementCount::getFixed(VF), - false /*HasGlobalPred*/); + const VFShape Shape = + VFShape::get(*CI, {VF, false} /*EC*/, false /*HasGlobalPred*/); #ifndef NDEBUG assert(VFDatabase(*CI).getVectorizedFunction(Shape) != nullptr && "Can't create vector function."); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 6d8a12a..6a5e8e2 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3029,7 +3029,7 @@ void BoUpSLP::buildTree_rec(ArrayRef VL, unsigned Depth, Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI); VFShape Shape = VFShape::get( - *CI, ElementCount::getFixed(static_cast(VL.size())), + *CI, {static_cast(VL.size()), false /*Scalable*/}, false /*HasGlobalPred*/); Function *VecFunc = VFDatabase(*CI).getVectorizedFunction(Shape); @@ -3264,9 +3264,9 @@ getVectorCallCosts(CallInst *CI, VectorType *VecTy, TargetTransformInfo *TTI, int IntrinsicCost = TTI->getIntrinsicInstrCost(CostAttrs, TTI::TCK_RecipThroughput); - auto Shape = VFShape::get(*CI, ElementCount::getFixed(static_cast( - VecTy->getNumElements())), - false /*HasGlobalPred*/); + auto Shape = + VFShape::get(*CI, {static_cast(VecTy->getNumElements()), false}, + false /*HasGlobalPred*/); Function *VecFunc = VFDatabase(*CI).getVectorizedFunction(Shape); int LibCost = IntrinsicCost; if (!CI->isNoBuiltin() && VecFunc) { @@ -4553,10 +4553,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { Function *CF; if (!UseIntrinsic) { - VFShape Shape = - VFShape::get(*CI, ElementCount::getFixed(static_cast( - VecTy->getNumElements())), - false /*HasGlobalPred*/); + VFShape Shape = VFShape::get( + *CI, {static_cast(VecTy->getNumElements()), false}, + false /*HasGlobalPred*/); CF = VFDatabase(*CI).getVectorizedFunction(Shape); } else { Type *Tys[] = {FixedVectorType::get(CI->getType(), E->Scalars.size())}; diff --git a/llvm/unittests/Analysis/VectorUtilsTest.cpp b/llvm/unittests/Analysis/VectorUtilsTest.cpp index c4e19c7..731ebdf 100644 --- a/llvm/unittests/Analysis/VectorUtilsTest.cpp +++ b/llvm/unittests/Analysis/VectorUtilsTest.cpp @@ -93,8 +93,7 @@ TEST_F(BasicTest, isSplat) { Value *SplatC = IRB.CreateVectorSplat(5, ScalarC); EXPECT_TRUE(isSplatValue(SplatC)); - Value *SplatC_SVE = - IRB.CreateVectorSplat(ElementCount::getScalable(5), ScalarC); + Value *SplatC_SVE = IRB.CreateVectorSplat(ElementCount(5, true), ScalarC); EXPECT_TRUE(isSplatValue(SplatC_SVE)); // FIXME: Constant splat analysis does not allow undef elements. @@ -503,7 +502,7 @@ protected: SmallVector &ExpectedParams = Expected.Parameters; void buildShape(unsigned VF, bool IsScalable, bool HasGlobalPred) { - Shape = VFShape::get(*CI, ElementCount::get(VF, IsScalable), HasGlobalPred); + Shape = VFShape::get(*CI, {VF, IsScalable}, HasGlobalPred); } bool validParams(ArrayRef Parameters) { diff --git a/llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp b/llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp index f1c4a8b..81c9916 100644 --- a/llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp +++ b/llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp @@ -49,12 +49,12 @@ TEST(ScalableVectorMVTsTest, HelperFuncs) { ASSERT_TRUE(Vnx4i32.isScalableVector()); // Create with separate llvm::ElementCount - auto EltCnt = ElementCount::getScalable(2); + auto EltCnt = ElementCount(2, true); EVT Vnx2i32 = EVT::getVectorVT(Ctx, MVT::i32, EltCnt); ASSERT_TRUE(Vnx2i32.isScalableVector()); // Create with inline llvm::ElementCount - EVT Vnx2i64 = EVT::getVectorVT(Ctx, MVT::i64, ElementCount::getScalable(2)); + EVT Vnx2i64 = EVT::getVectorVT(Ctx, MVT::i64, {2, true}); ASSERT_TRUE(Vnx2i64.isScalableVector()); // Check that changing scalar types/element count works @@ -66,7 +66,7 @@ TEST(ScalableVectorMVTsTest, HelperFuncs) { EXPECT_EQ(EVT::getVectorVT(Ctx, MVT::i64, EltCnt / 2), MVT::nxv1i64); // Check that float->int conversion works - EVT Vnx2f64 = EVT::getVectorVT(Ctx, MVT::f64, ElementCount::getScalable(2)); + EVT Vnx2f64 = EVT::getVectorVT(Ctx, MVT::f64, {2, true}); EXPECT_EQ(Vnx2f64.changeTypeToInteger(), Vnx2i64); // Check fields inside llvm::ElementCount @@ -77,7 +77,7 @@ TEST(ScalableVectorMVTsTest, HelperFuncs) { // Check that fixed-length vector types aren't scalable. EVT V8i32 = EVT::getVectorVT(Ctx, MVT::i32, 8); ASSERT_FALSE(V8i32.isScalableVector()); - EVT V4f64 = EVT::getVectorVT(Ctx, MVT::f64, ElementCount::getFixed(4)); + EVT V4f64 = EVT::getVectorVT(Ctx, MVT::f64, {4, false}); ASSERT_FALSE(V4f64.isScalableVector()); // Check that llvm::ElementCount works for fixed-length types. @@ -90,8 +90,7 @@ TEST(ScalableVectorMVTsTest, IRToVTTranslation) { LLVMContext Ctx; Type *Int64Ty = Type::getInt64Ty(Ctx); - VectorType *ScV8Int64Ty = - VectorType::get(Int64Ty, ElementCount::getScalable(8)); + VectorType *ScV8Int64Ty = VectorType::get(Int64Ty, {8, true}); // Check that we can map a scalable IR type to an MVT MVT Mnxv8i64 = MVT::getVT(ScV8Int64Ty); @@ -111,7 +110,7 @@ TEST(ScalableVectorMVTsTest, IRToVTTranslation) { TEST(ScalableVectorMVTsTest, VTToIRTranslation) { LLVMContext Ctx; - EVT Enxv4f64 = EVT::getVectorVT(Ctx, MVT::f64, ElementCount::getScalable(4)); + EVT Enxv4f64 = EVT::getVectorVT(Ctx, MVT::f64, {4, true}); Type *Ty = Enxv4f64.getTypeForEVT(Ctx); VectorType *ScV4Float64Ty = cast(Ty); diff --git a/llvm/unittests/FuzzMutate/OperationsTest.cpp b/llvm/unittests/FuzzMutate/OperationsTest.cpp index 4de3d43..c329d05 100644 --- a/llvm/unittests/FuzzMutate/OperationsTest.cpp +++ b/llvm/unittests/FuzzMutate/OperationsTest.cpp @@ -92,8 +92,8 @@ TEST(OperationsTest, SourcePreds) { ConstantStruct::get(StructType::create(Ctx, "OpaqueStruct")); Constant *a = ConstantArray::get(ArrayType::get(i32->getType(), 2), {i32, i32}); - Constant *v8i8 = ConstantVector::getSplat(ElementCount::getFixed(8), i8); - Constant *v4f16 = ConstantVector::getSplat(ElementCount::getFixed(4), f16); + Constant *v8i8 = ConstantVector::getSplat({8, false}, i8); + Constant *v4f16 = ConstantVector::getSplat({4, false}, f16); Constant *p0i32 = ConstantPointerNull::get(PointerType::get(i32->getType(), 0)); diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index 5fb2d2d..f1c1c86 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -646,8 +646,8 @@ TEST(ConstantsTest, GetSplatValueRoundTrip) { Type *Int8Ty = Type::getInt8Ty(Context); for (unsigned Min : {1, 2, 8}) { - auto ScalableEC = ElementCount::getScalable(Min); - auto FixedEC = ElementCount::getFixed(Min); + ElementCount ScalableEC = {Min, true}; + ElementCount FixedEC = {Min, false}; for (auto EC : {ScalableEC, FixedEC}) { for (auto *Ty : {FloatTy, Int32Ty, Int8Ty}) { diff --git a/llvm/unittests/IR/PatternMatch.cpp b/llvm/unittests/IR/PatternMatch.cpp index 97d8da5..8e6e48d 100644 --- a/llvm/unittests/IR/PatternMatch.cpp +++ b/llvm/unittests/IR/PatternMatch.cpp @@ -1445,8 +1445,8 @@ TEST_F(PatternMatchTest, ConstantPredicateType) { EXPECT_TRUE(match(CF32Pi, cstfp_pred_ty>())); EXPECT_FALSE(match(CF32Pi, cstfp_pred_ty>())); - auto FixedEC = ElementCount::getFixed(4); - auto ScalableEC = ElementCount::getScalable(4); + ElementCount FixedEC(4, false); + ElementCount ScalableEC(4, true); // Vector splat diff --git a/llvm/unittests/IR/VectorTypesTest.cpp b/llvm/unittests/IR/VectorTypesTest.cpp index b28e445..0dbf15e 100644 --- a/llvm/unittests/IR/VectorTypesTest.cpp +++ b/llvm/unittests/IR/VectorTypesTest.cpp @@ -59,13 +59,13 @@ TEST(VectorTypesTest, FixedLength) { dyn_cast(VectorType::get(Int32Ty, V8Int32Ty)); EXPECT_VTY_EQ(V8Int32Ty, V8Int32Ty2); - auto *V8Int16Ty = dyn_cast( - VectorType::get(Int16Ty, ElementCount::getFixed(8))); + auto *V8Int16Ty = + dyn_cast(VectorType::get(Int16Ty, {8, false})); ASSERT_NE(nullptr, V8Int16Ty); EXPECT_EQ(V8Int16Ty->getNumElements(), 8U); EXPECT_EQ(V8Int16Ty->getElementType()->getScalarSizeInBits(), 16U); - auto EltCnt = ElementCount::getFixed(4); + ElementCount EltCnt(4, false); auto *V4Int64Ty = dyn_cast(VectorType::get(Int64Ty, EltCnt)); ASSERT_NE(nullptr, V4Int64Ty); EXPECT_EQ(V4Int64Ty->getNumElements(), 4U); @@ -153,13 +153,13 @@ TEST(VectorTypesTest, Scalable) { dyn_cast(VectorType::get(Int32Ty, ScV8Int32Ty)); EXPECT_VTY_EQ(ScV8Int32Ty, ScV8Int32Ty2); - auto *ScV8Int16Ty = dyn_cast( - VectorType::get(Int16Ty, ElementCount::getScalable(8))); + auto *ScV8Int16Ty = + dyn_cast(VectorType::get(Int16Ty, {8, true})); ASSERT_NE(nullptr, ScV8Int16Ty); EXPECT_EQ(ScV8Int16Ty->getMinNumElements(), 8U); EXPECT_EQ(ScV8Int16Ty->getElementType()->getScalarSizeInBits(), 16U); - auto EltCnt = ElementCount::getScalable(4); + ElementCount EltCnt(4, true); auto *ScV4Int64Ty = dyn_cast(VectorType::get(Int64Ty, EltCnt)); ASSERT_NE(nullptr, ScV4Int64Ty); @@ -225,15 +225,14 @@ TEST(VectorTypesTest, BaseVectorType) { Type *Int16Ty = Type::getInt16Ty(Ctx); Type *Int32Ty = Type::getInt32Ty(Ctx); - std::array VTys = { - VectorType::get(Int16Ty, ElementCount::getScalable(4)), - VectorType::get(Int16Ty, ElementCount::getFixed(4)), - VectorType::get(Int16Ty, ElementCount::getScalable(2)), - VectorType::get(Int16Ty, ElementCount::getFixed(2)), - VectorType::get(Int32Ty, ElementCount::getScalable(4)), - VectorType::get(Int32Ty, ElementCount::getFixed(4)), - VectorType::get(Int32Ty, ElementCount::getScalable(2)), - VectorType::get(Int32Ty, ElementCount::getFixed(2))}; + std::array VTys = {VectorType::get(Int16Ty, {4, true}), + VectorType::get(Int16Ty, {4, false}), + VectorType::get(Int16Ty, {2, true}), + VectorType::get(Int16Ty, {2, false}), + VectorType::get(Int32Ty, {4, true}), + VectorType::get(Int32Ty, {4, false}), + VectorType::get(Int32Ty, {2, true}), + VectorType::get(Int32Ty, {2, false})}; /* The comparison matrix is symmetric, so we only check the upper triangle: diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index 174e3ee..f6a6a6e 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -57,7 +57,7 @@ TEST(VerifierTest, Freeze) { ConstantInt *CI = ConstantInt::get(ITy, 0); // Valid type : freeze(<2 x i32>) - Constant *CV = ConstantVector::getSplat(ElementCount::getFixed(2), CI); + Constant *CV = ConstantVector::getSplat({2, false}, CI); FreezeInst *FI_vec = new FreezeInst(CV); FI_vec->insertBefore(RI); -- 2.7.4