Skip to content

Commit 9821e90

Browse files
committed
Fixed calculation of constant v4i8 values.
1 parent 6a183b8 commit 9821e90

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,10 @@ SDValue NVPTXTargetLowering::LowerBUILD_VECTOR(SDValue Op,
22292229
Value = cast<ConstantSDNode>(Operand)->getAPIntValue();
22302230
else
22312231
llvm_unreachable("Unsupported type");
2232+
// i8 values are carried around as i16, so we need to zero out upper bits,
2233+
// so they do not get in the way of combining individual byte values
2234+
if (VT == MVT::v4i8)
2235+
Value = Value.trunc(8);
22322236
return Value.zext(32);
22332237
};
22342238
APInt Value;

llvm/test/CodeGen/NVPTX/i8x4-instructions.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ define <4 x i8> @test_ret_const() #0 {
1717
; CHECK-NEXT: .reg .b32 %r<3>;
1818
; CHECK-EMPTY:
1919
; CHECK-NEXT: // %bb.0:
20-
; CHECK-NEXT: mov.u32 %r1, 67305985;
20+
; CHECK-NEXT: mov.u32 %r1, -66911489;
2121
; CHECK-NEXT: st.param.b32 [func_retval0+0], %r1;
2222
; CHECK-NEXT: ret;
23-
ret <4 x i8> <i8 1, i8 2, i8 3, i8 4>
23+
ret <4 x i8> <i8 -1, i8 2, i8 3, i8 -4>
2424
}
2525

2626
define i8 @test_extract_0(<4 x i8> %a) #0 {

0 commit comments

Comments
 (0)