Skip to content

Commit 52415ec

Browse files
[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.
1 parent d345599 commit 52415ec

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

llvm/docs/GlobalISel/GenericOpcode.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,10 @@ G_SPLAT_VECTOR
690690

691691
Create a vector where all elements are the scalar from the source operand.
692692

693+
The type of the operand must be equal to or smaller than the vector element
694+
type. If the operand is smaller than the vector element type, the scalar is
695+
implicitly truncated to the vector element type.
696+
693697
Vector Reduction Operations
694698
---------------------------
695699

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,9 +1774,10 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
17741774
if (!SrcTy.isScalar())
17751775
report("Source type must be a scalar", MI);
17761776

1777-
if (DstTy.getScalarType() != SrcTy)
1778-
report("Element type of the destination must be the same type as the "
1779-
"source type",
1777+
if (TypeSize::isKnownGT(DstTy.getScalarType().getSizeInBits(),
1778+
SrcTy.getSizeInBits()))
1779+
report("Element type of the destination must be the same size or smaller "
1780+
"than the source type",
17801781
MI);
17811782

17821783
break;

llvm/test/MachineVerifier/test_g_splat_vector.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ body: |
2222
; CHECK: Source type must be a scalar
2323
%6:_(<vscale x 2 x s32>) = G_SPLAT_VECTOR %2
2424
25-
; CHECK: Element type of the destination must be the same type as the source type
26-
%7:_(<vscale x 2 x s64>) = G_SPLAT_VECTOR %0
25+
; CHECK: Element type of the destination must be the same size or smaller than the source type
26+
%7:_(<vscale x 2 x s128>) = G_SPLAT_VECTOR %0
2727
...

0 commit comments

Comments
 (0)