Skip to content

[NVPTX] Promote v2i8 to v2i16 #111189

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 1 commit into from
Oct 4, 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/lib/Target/NVPTX/NVPTXISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ static void ComputePTXValueVTs(const TargetLowering &TLI, const DataLayout &DL,
// v*i8 are formally lowered as v4i8
EltVT = MVT::v4i8;
NumElts = (NumElts + 3) / 4;
} else if (EltVT.getSimpleVT() == MVT::i8 && NumElts == 2) {
// v2i8 is promoted to v2i16
NumElts = 1;
EltVT = MVT::v2i16;
}
for (unsigned j = 0; j != NumElts; ++j) {
ValueVTs.push_back(EltVT);
Expand Down
15 changes: 11 additions & 4 deletions llvm/test/CodeGen/NVPTX/vector-returns.ll
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,17 @@ define <3 x i8> @byte3() {
ret <3 x i8> zeroinitializer
}

; FIXME: This test causes a crash.
; define <2 x i8> @byte2() {
; ret <2 x i8> zeroinitializer
; }
define <2 x i8> @byte2() {
; CHECK-LABEL: byte2(
; CHECK: {
; CHECK-NEXT: .reg .b32 %r<2>;
; CHECK-EMPTY:
; CHECK-NEXT: // %bb.0:
; CHECK-NEXT: mov.b32 %r1, 0;
; CHECK-NEXT: st.param.b32 [func_retval0+0], %r1;
; CHECK-NEXT: ret;
ret <2 x i8> zeroinitializer
Copy link
Member

Choose a reason for hiding this comment

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

It may be useful to use a non-zero value, so we can verify that we've stored the vector elements in correct order.
That, actually applies to all the tests here, so it may be worth fixing that in a separate patch.

}

define <1 x i8> @byte1() {
; CHECK-LABEL: byte1(
Expand Down
Loading