1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -check-prefix=GFX7 %s
3 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GFX8 %s
5 define i16 @v_trunc_i32_to_i16(i32 %src) {
6 ; GFX7-LABEL: v_trunc_i32_to_i16:
8 ; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
9 ; GFX7-NEXT: s_setpc_b64 s[30:31]
11 ; GFX8-LABEL: v_trunc_i32_to_i16:
13 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
14 ; GFX8-NEXT: s_setpc_b64 s[30:31]
15 %trunc = trunc i32 %src to i16
19 define amdgpu_ps i16 @s_trunc_i32_to_i16(i32 inreg %src) {
20 ; GFX7-LABEL: s_trunc_i32_to_i16:
22 ; GFX7-NEXT: ; return to shader part epilog
24 ; GFX8-LABEL: s_trunc_i32_to_i16:
26 ; GFX8-NEXT: ; return to shader part epilog
27 %trunc = trunc i32 %src to i16
31 define i16 @v_trunc_i64_to_i16(i64 %src) {
32 ; GFX7-LABEL: v_trunc_i64_to_i16:
34 ; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
35 ; GFX7-NEXT: s_setpc_b64 s[30:31]
37 ; GFX8-LABEL: v_trunc_i64_to_i16:
39 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
40 ; GFX8-NEXT: s_setpc_b64 s[30:31]
41 %trunc = trunc i64 %src to i16
45 define amdgpu_ps i16 @s_trunc_i64_to_i16(i64 inreg %src) {
46 ; GFX7-LABEL: s_trunc_i64_to_i16:
48 ; GFX7-NEXT: ; return to shader part epilog
50 ; GFX8-LABEL: s_trunc_i64_to_i16:
52 ; GFX8-NEXT: ; return to shader part epilog
53 %trunc = trunc i64 %src to i16
57 define amdgpu_ps i16 @s_trunc_i128_to_i16(i128 inreg %src) {
58 ; GFX7-LABEL: s_trunc_i128_to_i16:
60 ; GFX7-NEXT: ; return to shader part epilog
62 ; GFX8-LABEL: s_trunc_i128_to_i16:
64 ; GFX8-NEXT: ; return to shader part epilog
65 %trunc = trunc i128 %src to i16
69 define i16 @v_trunc_i128_to_i16(i128 %src) {
70 ; GFX7-LABEL: v_trunc_i128_to_i16:
72 ; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
73 ; GFX7-NEXT: s_setpc_b64 s[30:31]
75 ; GFX8-LABEL: v_trunc_i128_to_i16:
77 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78 ; GFX8-NEXT: s_setpc_b64 s[30:31]
79 %trunc = trunc i128 %src to i16
83 define i32 @v_trunc_v2i32_to_v2i16(<2 x i32> %src) {
84 ; GFX7-LABEL: v_trunc_v2i32_to_v2i16:
86 ; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
87 ; GFX7-NEXT: v_lshlrev_b32_e32 v1, 16, v1
88 ; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0
89 ; GFX7-NEXT: v_or_b32_e32 v0, v1, v0
90 ; GFX7-NEXT: s_setpc_b64 s[30:31]
92 ; GFX8-LABEL: v_trunc_v2i32_to_v2i16:
94 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
95 ; GFX8-NEXT: v_mov_b32_sdwa v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0
96 ; GFX8-NEXT: s_setpc_b64 s[30:31]
97 %trunc = trunc <2 x i32> %src to <2 x i16>
98 %cast = bitcast <2 x i16> %trunc to i32
102 define amdgpu_ps i32 @s_trunc_v2i32_to_v2i16(<2 x i32> inreg %src) {
103 ; GFX7-LABEL: s_trunc_v2i32_to_v2i16:
105 ; GFX7-NEXT: s_lshl_b32 s1, s1, 16
106 ; GFX7-NEXT: s_and_b32 s0, s0, 0xffff
107 ; GFX7-NEXT: s_or_b32 s0, s1, s0
108 ; GFX7-NEXT: ; return to shader part epilog
110 ; GFX8-LABEL: s_trunc_v2i32_to_v2i16:
112 ; GFX8-NEXT: s_lshl_b32 s1, s1, 16
113 ; GFX8-NEXT: s_and_b32 s0, s0, 0xffff
114 ; GFX8-NEXT: s_or_b32 s0, s1, s0
115 ; GFX8-NEXT: ; return to shader part epilog
116 %trunc = trunc <2 x i32> %src to <2 x i16>
117 %cast = bitcast <2 x i16> %trunc to i32
121 ; ; FIXME: G_INSERT mishandled
122 ; define <2 x i32> @v_trunc_v3i32_to_v3i16(<3 x i32> %src) {
123 ; %trunc = trunc <3 x i32> %src to <3 x i16>
124 ; %ext = shufflevector <3 x i16> %trunc, <3 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
125 ; %cast = bitcast <4 x i16> %ext to <2 x i32>
126 ; ret <2 x i32> %cast
129 ; ; FIXME: G_INSERT mishandled
130 ; define amdgpu_ps <2 x i32> @s_trunc_v3i32_to_v3i16(<3 x i32> inreg %src) {
131 ; %trunc = trunc <3 x i32> %src to <3 x i16>
132 ; %ext = shufflevector <3 x i16> %trunc, <3 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
133 ; %cast = bitcast <4 x i16> %ext to <2 x i32>
134 ; ret <2 x i32> %cast
137 define <2 x i32> @v_trunc_v4i32_to_v4i16(<4 x i32> %src) {
138 ; GFX7-LABEL: v_trunc_v4i32_to_v4i16:
140 ; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
141 ; GFX7-NEXT: v_lshlrev_b32_e32 v1, 16, v1
142 ; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0
143 ; GFX7-NEXT: v_or_b32_e32 v0, v1, v0
144 ; GFX7-NEXT: v_lshlrev_b32_e32 v1, 16, v3
145 ; GFX7-NEXT: v_and_b32_e32 v2, 0xffff, v2
146 ; GFX7-NEXT: v_or_b32_e32 v1, v1, v2
147 ; GFX7-NEXT: s_setpc_b64 s[30:31]
149 ; GFX8-LABEL: v_trunc_v4i32_to_v4i16:
151 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
152 ; GFX8-NEXT: v_mov_b32_sdwa v2, v3 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0
153 ; GFX8-NEXT: v_mov_b32_sdwa v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0
154 ; GFX8-NEXT: v_mov_b32_e32 v1, v2
155 ; GFX8-NEXT: s_setpc_b64 s[30:31]
156 %trunc = trunc <4 x i32> %src to <4 x i16>
157 %cast = bitcast <4 x i16> %trunc to <2 x i32>
161 define amdgpu_ps <2 x i32> @s_trunc_v4i32_to_v4i16(<4 x i32> inreg %src) {
162 ; GFX7-LABEL: s_trunc_v4i32_to_v4i16:
164 ; GFX7-NEXT: s_lshl_b32 s1, s1, 16
165 ; GFX7-NEXT: s_and_b32 s0, s0, 0xffff
166 ; GFX7-NEXT: s_or_b32 s0, s1, s0
167 ; GFX7-NEXT: s_lshl_b32 s1, s3, 16
168 ; GFX7-NEXT: s_and_b32 s2, s2, 0xffff
169 ; GFX7-NEXT: s_or_b32 s1, s1, s2
170 ; GFX7-NEXT: ; return to shader part epilog
172 ; GFX8-LABEL: s_trunc_v4i32_to_v4i16:
174 ; GFX8-NEXT: s_lshl_b32 s1, s1, 16
175 ; GFX8-NEXT: s_and_b32 s0, s0, 0xffff
176 ; GFX8-NEXT: s_or_b32 s0, s1, s0
177 ; GFX8-NEXT: s_lshl_b32 s1, s3, 16
178 ; GFX8-NEXT: s_and_b32 s2, s2, 0xffff
179 ; GFX8-NEXT: s_or_b32 s1, s1, s2
180 ; GFX8-NEXT: ; return to shader part epilog
181 %trunc = trunc <4 x i32> %src to <4 x i16>
182 %cast = bitcast <4 x i16> %trunc to <2 x i32>