Skip to content

Commit

Permalink
[MachineValueType] Don't allow MVT::getVectorNumElements() to be call…
Browse files Browse the repository at this point in the history
…ed for scalable vectors.

Migrate the one caller that failed lit tests to use
MVT::getVectorMinNumElements directly.
  • Loading branch information
topperc committed Jan 13, 2022
1 parent 55029f0 commit 1e04923
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion llvm/include/llvm/Support/MachineValueType.h
Expand Up @@ -848,7 +848,11 @@ namespace llvm {
}

unsigned getVectorNumElements() const {
// TODO: Check that this isn't a scalable vector.
if (isScalableVector())
llvm::reportInvalidSizeRequest(
"Possible incorrect use of MVT::getVectorNumElements() for "
"scalable vector. Scalable flag may be dropped, use "
"MVT::getVectorElementCount() instead");
return getVectorMinNumElements();
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/LowLevelType.cpp
Expand Up @@ -17,7 +17,7 @@ using namespace llvm;

LLT::LLT(MVT VT) {
if (VT.isVector()) {
bool asVector = VT.getVectorNumElements() > 1;
bool asVector = VT.getVectorMinNumElements() > 1;
init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(),
/*AddressSpace=*/0);
Expand Down

0 comments on commit 1e04923

Please sign in to comment.