diff options
author | Michael Maitland <michaeltmaitland@gmail.com> | 2024-04-01 08:46:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-01 08:46:22 -0400 |
commit | da9f06c9b1179423302e3e7ccb27431ced44e548 (patch) | |
tree | ecec6f06bc5e5ab8f6a989d12387c3e8d6554eba | |
parent | 4213f4a9ae0ef70e02da9f40653b4e04eea00c74 (diff) | |
download | llvm-da9f06c9b1179423302e3e7ccb27431ced44e548.zip llvm-da9f06c9b1179423302e3e7ccb27431ced44e548.tar.gz llvm-da9f06c9b1179423302e3e7ccb27431ced44e548.tar.bz2 |
[GISEL] G_SPLAT_VECTOR can take a splat that is larger than the vector element (#86974)
This is what SelectionDAG does. We'd like to reuse SelectionDAG
patterns.
-rw-r--r-- | llvm/docs/GlobalISel/GenericOpcode.rst | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 17 | ||||
-rw-r--r-- | llvm/test/MachineVerifier/test_g_splat_vector.mir | 4 |
3 files changed, 18 insertions, 7 deletions
diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst index cae2c21..a12627c 100644 --- a/llvm/docs/GlobalISel/GenericOpcode.rst +++ b/llvm/docs/GlobalISel/GenericOpcode.rst @@ -690,6 +690,10 @@ G_SPLAT_VECTOR Create a vector where all elements are the scalar from the source operand. +The type of the operand must be equal to or larger than the vector element +type. If the operand is larger than the vector element type, the scalar is +implicitly truncated to the vector element type. + Vector Reduction Operations --------------------------- diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index e4e05ce..fd7ea284 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1768,16 +1768,23 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { LLT DstTy = MRI->getType(MI->getOperand(0).getReg()); LLT SrcTy = MRI->getType(MI->getOperand(1).getReg()); - if (!DstTy.isScalableVector()) + if (!DstTy.isScalableVector()) { report("Destination type must be a scalable vector", MI); + break; + } - if (!SrcTy.isScalar()) + if (!SrcTy.isScalar()) { report("Source type must be a scalar", MI); + break; + } - if (DstTy.getScalarType() != SrcTy) - report("Element type of the destination must be the same type as the " - "source type", + if (TypeSize::isKnownGT(DstTy.getElementType().getSizeInBits(), + SrcTy.getSizeInBits())) { + report("Element type of the destination must be the same size or smaller " + "than the source type", MI); + break; + } break; } diff --git a/llvm/test/MachineVerifier/test_g_splat_vector.mir b/llvm/test/MachineVerifier/test_g_splat_vector.mir index 0d1d8a3..0007434 100644 --- a/llvm/test/MachineVerifier/test_g_splat_vector.mir +++ b/llvm/test/MachineVerifier/test_g_splat_vector.mir @@ -22,6 +22,6 @@ body: | ; CHECK: Source type must be a scalar %6:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %2 - ; CHECK: Element type of the destination must be the same type as the source type - %7:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR %0 + ; CHECK: Element type of the destination must be the same size or smaller than the source type + %7:_(<vscale x 2 x s128>) = G_SPLAT_VECTOR %0 ... |