Skip to content

Commit fda2fea

Browse files
authored
[NVPTX] Promote v2i8 to v2i16 (#111189)
Promote v2i8 to v2i16, fixes a crash. Re-enable a test in NVPTX/vector-returns.ll #104864
1 parent b2f3ac8 commit fda2fea

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ static void ComputePTXValueVTs(const TargetLowering &TLI, const DataLayout &DL,
236236
// v*i8 are formally lowered as v4i8
237237
EltVT = MVT::v4i8;
238238
NumElts = (NumElts + 3) / 4;
239+
} else if (EltVT.getSimpleVT() == MVT::i8 && NumElts == 2) {
240+
// v2i8 is promoted to v2i16
241+
NumElts = 1;
242+
EltVT = MVT::v2i16;
239243
}
240244
for (unsigned j = 0; j != NumElts; ++j) {
241245
ValueVTs.push_back(EltVT);

llvm/test/CodeGen/NVPTX/vector-returns.ll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,17 @@ define <3 x i8> @byte3() {
325325
ret <3 x i8> zeroinitializer
326326
}
327327

328-
; FIXME: This test causes a crash.
329-
; define <2 x i8> @byte2() {
330-
; ret <2 x i8> zeroinitializer
331-
; }
328+
define <2 x i8> @byte2() {
329+
; CHECK-LABEL: byte2(
330+
; CHECK: {
331+
; CHECK-NEXT: .reg .b32 %r<2>;
332+
; CHECK-EMPTY:
333+
; CHECK-NEXT: // %bb.0:
334+
; CHECK-NEXT: mov.b32 %r1, 0;
335+
; CHECK-NEXT: st.param.b32 [func_retval0+0], %r1;
336+
; CHECK-NEXT: ret;
337+
ret <2 x i8> zeroinitializer
338+
}
332339

333340
define <1 x i8> @byte1() {
334341
; CHECK-LABEL: byte1(

0 commit comments

Comments
 (0)