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 @@ -520,12 +520,6 @@ return EC; } - /// Return the minimum number of bits in the Vector type. - /// Returns zero when the vector is a vector of pointers. - unsigned getBitWidth() const { - return getNumElements() * getElementType()->getPrimitiveSizeInBits(); - } - /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool classof(const Type *T) { return T->getTypeID() == FixedVectorTyID || diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -68,20 +68,23 @@ return false; // Vector -> Vector conversions are always lossless if the two vector types - // have the same size, otherwise not. Also, 64-bit vector types can be + // have the same size, otherwise not. Also, 64-bit fixed vector types can be // converted to x86mmx. - if (auto *thisPTy = dyn_cast(this)) { - if (auto *thatPTy = dyn_cast(Ty)) - return thisPTy->getBitWidth() == thatPTy->getBitWidth(); - if (Ty->getTypeID() == Type::X86_MMXTyID && - thisPTy->getBitWidth() == 64) + if (isa(this)) { + TypeSize ThisTypeSize = getPrimitiveSizeInBits(); + if (isa(Ty)) + return ThisTypeSize == Ty->getPrimitiveSizeInBits(); + if (Ty->getTypeID() == Type::X86_MMXTyID && !ThisTypeSize.isScalable() && + ThisTypeSize.getFixedSize() == 64) return true; } if (this->getTypeID() == Type::X86_MMXTyID) - if (auto *thatPTy = dyn_cast(Ty)) - if (thatPTy->getBitWidth() == 64) + if (isa(Ty)) { + TypeSize ThatTypeSize = Ty->getPrimitiveSizeInBits(); + if (ThatTypeSize.getFixedSize() == 64) return true; + } // At this point we have only various mismatches of the first class types // remaining and ptr->ptr. Just select the lossless conversions. Everything @@ -126,7 +129,10 @@ case Type::FixedVectorTyID: case Type::ScalableVectorTyID: { const VectorType *VTy = cast(this); - return TypeSize(VTy->getBitWidth(), isa(VTy)); + ElementCount EC = VTy->getElementCount(); + TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits(); + assert(!ETS.isScalable() && "Vector type should have fixed-width elements"); + return {ETS.getFixedSize() * EC.Min, EC.Scalable}; } default: return TypeSize::Fixed(0); }