diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -7573,8 +7573,7 @@ // The vector type that is stored may be different from the // eventual type stored to memory. auto VectorTy = cast(Ops.back()->getType()); - auto MemoryTy = - llvm::VectorType::get(MemEltTy, VectorTy->getVectorElementCount()); + auto MemoryTy = llvm::VectorType::get(MemEltTy, VectorTy->getElementCount()); Value *Predicate = EmitSVEPredicateCast(Ops[0], MemoryTy); Value *BasePtr = Builder.CreateBitCast(Ops[1], MemoryTy->getPointerTo()); diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -531,18 +531,6 @@ } }; -unsigned Type::getVectorNumElements() const { - return cast(this)->getNumElements(); -} - -bool Type::getVectorIsScalable() const { - return cast(this)->isScalable(); -} - -ElementCount Type::getVectorElementCount() const { - return cast(this)->getElementCount(); -} - bool Type::isVectorTy() const { return isa(this); } /// Class to represent pointers. @@ -597,8 +585,8 @@ isIntOrIntVectorTy() && "Original type expected to be a vector of integers or a scalar integer."); Type *NewType = getIntNTy(getContext(), NewBitWidth); - if (isVectorTy()) - NewType = VectorType::get(NewType, getVectorElementCount()); + if (auto *VTy = dyn_cast(this)) + NewType = VectorType::get(NewType, VTy->getElementCount()); return NewType; } @@ -606,6 +594,12 @@ return cast(getScalarType())->getAddressSpace(); } +Type *Type::getScalarType() const { + if (isVectorTy()) + return cast(this)->getElementType(); + return const_cast(this); +} + } // end namespace llvm #endif // LLVM_IR_DERIVEDTYPES_H diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -300,11 +300,7 @@ /// If this is a vector type, return the element type, otherwise return /// 'this'. - Type *getScalarType() const { - if (isVectorTy()) - return getVectorElementType(); - return const_cast(this); - } + inline Type *getScalarType() const; //===--------------------------------------------------------------------===// // Type Iteration support. @@ -339,8 +335,8 @@ //===--------------------------------------------------------------------===// // Helper methods corresponding to subclass methods. This forces a cast to - // the specified subclass and calls its accessor. "getVectorNumElements" (for - // example) is shorthand for cast(Ty)->getNumElements(). This is + // the specified subclass and calls its accessor. "getArrayNumElements" (for + // example) is shorthand for cast(Ty)->getNumElements(). This is // only intended to cover the core methods that are frequently used, helper // methods should not be added here. @@ -361,14 +357,6 @@ return ContainedTys[0]; } - inline bool getVectorIsScalable() const; - inline unsigned getVectorNumElements() const; - inline ElementCount getVectorElementCount() const; - Type *getVectorElementType() const { - assert(getTypeID() == VectorTyID); - return ContainedTys[0]; - } - Type *getPointerElementType() const { assert(getTypeID() == PointerTyID); return ContainedTys[0]; diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -5262,7 +5262,7 @@ if (!RewriteGEP && Ops.size() == 2) return false; - unsigned NumElts = Ptr->getType()->getVectorNumElements(); + unsigned NumElts = cast(Ptr->getType())->getNumElements(); IRBuilder<> Builder(MemoryInst); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4263,7 +4263,7 @@ Base = SDB->getValue(C); - unsigned NumElts = Ptr->getType()->getVectorNumElements(); + unsigned NumElts = cast(Ptr->getType())->getNumElements(); EVT VT = EVT::getVectorVT(*DAG.getContext(), TLI.getPointerTy(DL), NumElts); Index = DAG.getConstant(0, SDB->getCurSDLoc(), VT); IndexType = ISD::SIGNED_SCALED; diff --git a/llvm/unittests/IR/VPIntrinsicTest.cpp b/llvm/unittests/IR/VPIntrinsicTest.cpp --- a/llvm/unittests/IR/VPIntrinsicTest.cpp +++ b/llvm/unittests/IR/VPIntrinsicTest.cpp @@ -107,7 +107,7 @@ if (MaskParamPos.hasValue()) { Type *MaskParamType = F.getArg(MaskParamPos.getValue())->getType(); ASSERT_TRUE(MaskParamType->isVectorTy()); - ASSERT_TRUE(MaskParamType->getVectorElementType()->isIntegerTy(1)); + ASSERT_TRUE(cast(MaskParamType)->getElementType()->isIntegerTy(1)); } Optional VecLenParamPos =