Skip to content

Commit 1e04923

Browse files
committed
[MachineValueType] Don't allow MVT::getVectorNumElements() to be called for scalable vectors.
Migrate the one caller that failed lit tests to use MVT::getVectorMinNumElements directly.
1 parent 55029f0 commit 1e04923

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/include/llvm/Support/MachineValueType.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,11 @@ namespace llvm {
848848
}
849849

850850
unsigned getVectorNumElements() const {
851-
// TODO: Check that this isn't a scalable vector.
851+
if (isScalableVector())
852+
llvm::reportInvalidSizeRequest(
853+
"Possible incorrect use of MVT::getVectorNumElements() for "
854+
"scalable vector. Scalable flag may be dropped, use "
855+
"MVT::getVectorElementCount() instead");
852856
return getVectorMinNumElements();
853857
}
854858

llvm/lib/Support/LowLevelType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using namespace llvm;
1717

1818
LLT::LLT(MVT VT) {
1919
if (VT.isVector()) {
20-
bool asVector = VT.getVectorNumElements() > 1;
20+
bool asVector = VT.getVectorMinNumElements() > 1;
2121
init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
2222
VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(),
2323
/*AddressSpace=*/0);

0 commit comments

Comments
 (0)