Skip to content

[GISEL] G_SPLAT_VECTOR can take a splat that is larger than the vector element #86974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/docs/GlobalISel/GenericOpcode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it all backwards 😆 . The operand should be allowed to be greater than the size of the vector element.


Vector Reduction Operations
---------------------------

Expand Down
17 changes: 12 additions & 5 deletions llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MachineVerifier/test_g_splat_vector.mir
Original file line number Diff line number Diff line change
Expand Up @@ -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
...