[PATCH] D77833: [SVE] Remove VectorType::getBitWidth()
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 15:16:06 PDT 2020
ctetreau created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
- VectorType::getBitWidth() is just an unsafe version of
getPrimitiveSizeInBits() that assumes all vectors are fixed width.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77833
Files:
llvm/include/llvm/IR/DerivedTypes.h
llvm/lib/IR/Type.cpp
Index: llvm/lib/IR/Type.cpp
===================================================================
--- llvm/lib/IR/Type.cpp
+++ 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<VectorType>(this)) {
- if (auto *thatPTy = dyn_cast<VectorType>(Ty))
- return thisPTy->getBitWidth() == thatPTy->getBitWidth();
- if (Ty->getTypeID() == Type::X86_MMXTyID &&
- thisPTy->getBitWidth() == 64)
+ if (isa<VectorType>(this)) {
+ TypeSize ThisTypeSize = getPrimitiveSizeInBits();
+ if (isa<VectorType>(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<VectorType>(Ty))
- if (thatPTy->getBitWidth() == 64)
+ if (isa<FixedVectorType>(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<VectorType>(this);
- return TypeSize(VTy->getBitWidth(), isa<ScalableVectorType>(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);
}
Index: llvm/include/llvm/IR/DerivedTypes.h
===================================================================
--- llvm/include/llvm/IR/DerivedTypes.h
+++ 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 ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77833.256421.patch
Type: text/x-patch
Size: 2653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/ca879d72/attachment.bin>
More information about the llvm-commits
mailing list