llvm.org GIT mirror llvm / 4835c04
AMDGPU: Fix assert in truncate combine with vectors The piece above probably has the same problem, but I need to try to come up with a test for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336935 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 1 year, 7 months ago
2 changed file(s) with 28 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
30203020 // Equivalent of above for accessing the high element of a vector as an
30213021 // integer operation.
30223022 // trunc (srl (bitcast (build_vector x, y))), 16 -> trunc (bitcast y)
3023 if (Src.getOpcode() == ISD::SRL) {
3023 if (Src.getOpcode() == ISD::SRL && !VT.isVector()) {
30243024 if (auto K = isConstOrConstSplat(Src.getOperand(1))) {
30253025 if (2 * K->getZExtValue() == Src.getValueType().getScalarSizeInBits()) {
30263026 SDValue BV = stripBitcast(Src.getOperand(0));
5252 %add = add i16 %trunc, 4
5353 ret i16 %add
5454 }
55
56 ; GCN-LABEL: {{^}}truncate_high_elt_extract_vector:
57 ; GCN: s_load_dword s
58 ; GCN: s_load_dword s
59 ; GCN: s_sext_i32_i16
60 ; GCN: s_sext_i32_i16
61 ; GCN: v_mul_i32_i24
62 ; GCN: v_lshrrev_b32_e32
63 define amdgpu_kernel void @truncate_high_elt_extract_vector(<2 x i16> addrspace(1)* nocapture readonly %arg, <2 x i16> addrspace(1)* nocapture readonly %arg1, <2 x i16> addrspace(1)* nocapture %arg2) local_unnamed_addr {
64 bb:
65 %tmp = getelementptr inbounds <2 x i16>, <2 x i16> addrspace(1)* %arg, i64 undef
66 %tmp3 = load <2 x i16>, <2 x i16> addrspace(1)* %tmp, align 4
67 %tmp4 = getelementptr inbounds <2 x i16>, <2 x i16> addrspace(1)* %arg1, i64 undef
68 %tmp5 = load <2 x i16>, <2 x i16> addrspace(1)* %tmp4, align 4
69 %tmp6 = sext <2 x i16> %tmp3 to <2 x i32>
70 %tmp7 = sext <2 x i16> %tmp5 to <2 x i32>
71 %tmp8 = extractelement <2 x i32> %tmp6, i64 0
72 %tmp9 = extractelement <2 x i32> %tmp7, i64 0
73 %tmp10 = mul nsw i32 %tmp9, %tmp8
74 %tmp11 = insertelement <2 x i32> undef, i32 %tmp10, i32 0
75 %tmp12 = insertelement <2 x i32> %tmp11, i32 undef, i32 1
76 %tmp13 = lshr <2 x i32> %tmp12,
77 %tmp14 = trunc <2 x i32> %tmp13 to <2 x i16>
78 %tmp15 = getelementptr inbounds <2 x i16>, <2 x i16> addrspace(1)* %arg2, i64 undef
79 store <2 x i16> %tmp14, <2 x i16> addrspace(1)* %tmp15, align 4
80 ret void
81 }