[llvm] [GISEL] G_SPLAT_VECTOR can take a splat that is smaller than the vector element (PR #86974)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 09:35:26 PDT 2024
https://github.com/michaelmaitland created https://github.com/llvm/llvm-project/pull/86974
This is what SelectionDAG does. We'd like to reuse SelectionDAG patterns.
>From 465cbd5fcff1e08a2ed1ca614166e004fcfa3741 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 28 Mar 2024 09:25:55 -0700
Subject: [PATCH] [GISEL] G_SPLAT_VECTOR can take a splat that is smaller than
the vector element
This is what SelectionDAG does. We'd like to reuse SelectionDAG patterns.
---
llvm/docs/GlobalISel/GenericOpcode.rst | 4 ++++
llvm/lib/CodeGen/MachineVerifier.cpp | 7 ++++---
llvm/test/MachineVerifier/test_g_splat_vector.mir | 4 ++--
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst
index cae2c21b80d7e7..e3ec5272c1e167 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 smaller than the vector element
+type. If the operand is smaller 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..e568a379b213e6 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1774,9 +1774,10 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
if (!SrcTy.isScalar())
report("Source type must be a scalar", MI);
- if (DstTy.getScalarType() != SrcTy)
- report("Element type of the destination must be the same type as the "
- "source type",
+ if (TypeSize::isKnownGT(DstTy.getScalarType().getSizeInBits(),
+ SrcTy.getSizeInBits()))
+ report("Element type of the destination must be the same size or smaller "
+ "than the source type",
MI);
break;
diff --git a/llvm/test/MachineVerifier/test_g_splat_vector.mir b/llvm/test/MachineVerifier/test_g_splat_vector.mir
index 0d1d8a3e6dcc64..c5d0c1b61f3915 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 %7
...
More information about the llvm-commits
mailing list