[llvm] da9f06c - [GISEL] G_SPLAT_VECTOR can take a splat that is larger than the vector element (#86974)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 1 05:46:27 PDT 2024
Author: Michael Maitland
Date: 2024-04-01T08:46:22-04:00
New Revision: da9f06c9b1179423302e3e7ccb27431ced44e548
URL: https://github.com/llvm/llvm-project/commit/da9f06c9b1179423302e3e7ccb27431ced44e548
DIFF: https://github.com/llvm/llvm-project/commit/da9f06c9b1179423302e3e7ccb27431ced44e548.diff
LOG: [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.
Added:
Modified:
llvm/docs/GlobalISel/GenericOpcode.rst
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/test/MachineVerifier/test_g_splat_vector.mir
Removed:
################################################################################
diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst
index cae2c21b80d7e7..a12627c01d205b 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 e4e05ce9278caf..fd7ea28426470a 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 0d1d8a3e6dcc64..00074349776fa7 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
...
More information about the llvm-commits
mailing list