1; RUN: opt -S -mtriple=amdgcn-- -amdgpu-codegenprepare %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
2; RUN: opt -S -mtriple=amdgcn-- -mcpu=tonga -amdgpu-codegenprepare %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
3
4; GCN-LABEL: @add_i3(
5; SI: %r = add i3 %a, %b
6; SI-NEXT: store volatile i3 %r
7; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
8; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
9; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
10; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
11; VI-NEXT: store volatile i3 %[[R_3]]
12define amdgpu_kernel void @add_i3(i3 %a, i3 %b) {
13  %r = add i3 %a, %b
14  store volatile i3 %r, i3 addrspace(1)* undef
15  ret void
16}
17
18; GCN-LABEL: @add_nsw_i3(
19; SI: %r = add nsw i3 %a, %b
20; SI-NEXT: store volatile i3 %r
21; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
22; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
23; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
24; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
25; VI-NEXT: store volatile i3 %[[R_3]]
26define amdgpu_kernel void @add_nsw_i3(i3 %a, i3 %b) {
27  %r = add nsw i3 %a, %b
28  store volatile i3 %r, i3 addrspace(1)* undef
29  ret void
30}
31
32; GCN-LABEL: @add_nuw_i3(
33; SI: %r = add nuw i3 %a, %b
34; SI-NEXT: store volatile i3 %r
35; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
36; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
37; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
38; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
39; VI-NEXT: store volatile i3 %[[R_3]]
40define amdgpu_kernel void @add_nuw_i3(i3 %a, i3 %b) {
41  %r = add nuw i3 %a, %b
42  store volatile i3 %r, i3 addrspace(1)* undef
43  ret void
44}
45
46; GCN-LABEL: @add_nuw_nsw_i3(
47; SI: %r = add nuw nsw i3 %a, %b
48; SI-NEXT: store volatile i3 %r
49; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
50; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
51; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
52; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
53; VI-NEXT: store volatile i3 %[[R_3]]
54define amdgpu_kernel void @add_nuw_nsw_i3(i3 %a, i3 %b) {
55  %r = add nuw nsw i3 %a, %b
56  store volatile i3 %r, i3 addrspace(1)* undef
57  ret void
58}
59
60; GCN-LABEL: @sub_i3(
61; SI: %r = sub i3 %a, %b
62; SI-NEXT: store volatile i3 %r
63; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
64; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
65; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw i32 %[[A_32]], %[[B_32]]
66; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
67; VI-NEXT: store volatile i3 %[[R_3]]
68define amdgpu_kernel void @sub_i3(i3 %a, i3 %b) {
69  %r = sub i3 %a, %b
70  store volatile i3 %r, i3 addrspace(1)* undef
71  ret void
72}
73
74; GCN-LABEL: @sub_nsw_i3(
75; SI: %r = sub nsw i3 %a, %b
76; SI-NEXT: store volatile i3 %r
77; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
78; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
79; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw i32 %[[A_32]], %[[B_32]]
80; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
81; VI-NEXT: store volatile i3 %[[R_3]]
82define amdgpu_kernel void @sub_nsw_i3(i3 %a, i3 %b) {
83  %r = sub nsw i3 %a, %b
84  store volatile i3 %r, i3 addrspace(1)* undef
85  ret void
86}
87
88; GCN-LABEL: @sub_nuw_i3(
89; SI: %r = sub nuw i3 %a, %b
90; SI-NEXT: store volatile i3 %r
91; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
92; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
93; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw i32 %[[A_32]], %[[B_32]]
94; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
95; VI-NEXT: store volatile i3 %[[R_3]]
96define amdgpu_kernel void @sub_nuw_i3(i3 %a, i3 %b) {
97  %r = sub nuw i3 %a, %b
98  store volatile i3 %r, i3 addrspace(1)* undef
99  ret void
100}
101
102; GCN-LABEL: @sub_nuw_nsw_i3(
103; SI: %r = sub nuw nsw i3 %a, %b
104; SI-NEXT: store volatile i3 %r
105; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
106; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
107; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw i32 %[[A_32]], %[[B_32]]
108; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
109; VI-NEXT: store volatile i3 %[[R_3]]
110define amdgpu_kernel void @sub_nuw_nsw_i3(i3 %a, i3 %b) {
111  %r = sub nuw nsw i3 %a, %b
112  store volatile i3 %r, i3 addrspace(1)* undef
113  ret void
114}
115
116; GCN-LABEL: @mul_i3(
117; SI: %r = mul i3 %a, %b
118; SI-NEXT: store volatile i3 %r
119; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
120; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
121; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw i32 %[[A_32]], %[[B_32]]
122; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
123; VI-NEXT: store volatile i3 %[[R_3]]
124define amdgpu_kernel void @mul_i3(i3 %a, i3 %b) {
125  %r = mul i3 %a, %b
126  store volatile i3 %r, i3 addrspace(1)* undef
127  ret void
128}
129
130; GCN-LABEL: @mul_nsw_i3(
131; SI: %r = mul nsw i3 %a, %b
132; SI-NEXT: store volatile i3 %r
133; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
134; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
135; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw i32 %[[A_32]], %[[B_32]]
136; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
137; VI-NEXT: store volatile i3 %[[R_3]]
138define amdgpu_kernel void @mul_nsw_i3(i3 %a, i3 %b) {
139  %r = mul nsw i3 %a, %b
140  store volatile i3 %r, i3 addrspace(1)* undef
141  ret void
142}
143
144; GCN-LABEL: @mul_nuw_i3(
145; SI: %r = mul nuw i3 %a, %b
146; SI-NEXT: store volatile i3 %r
147; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
148; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
149; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw i32 %[[A_32]], %[[B_32]]
150; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
151; VI-NEXT: store volatile i3 %[[R_3]]
152define amdgpu_kernel void @mul_nuw_i3(i3 %a, i3 %b) {
153  %r = mul nuw i3 %a, %b
154  store volatile i3 %r, i3 addrspace(1)* undef
155  ret void
156}
157
158; GCN-LABEL: @mul_nuw_nsw_i3(
159; SI: %r = mul nuw nsw i3 %a, %b
160; SI-NEXT: store volatile i3 %r
161; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
162; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
163; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw i32 %[[A_32]], %[[B_32]]
164; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
165; VI-NEXT: store volatile i3 %[[R_3]]
166define amdgpu_kernel void @mul_nuw_nsw_i3(i3 %a, i3 %b) {
167  %r = mul nuw nsw i3 %a, %b
168  store volatile i3 %r, i3 addrspace(1)* undef
169  ret void
170}
171
172; GCN-LABEL: @urem_i3(
173; SI: %r = urem i3 %a, %b
174; SI-NEXT: store volatile i3 %r
175; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
176; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
177; VI-NEXT: %[[R_32:[0-9]+]] = urem i32 %[[A_32]], %[[B_32]]
178; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
179; VI-NEXT: store volatile i3 %[[R_3]]
180define amdgpu_kernel void @urem_i3(i3 %a, i3 %b) {
181  %r = urem i3 %a, %b
182  store volatile i3 %r, i3 addrspace(1)* undef
183  ret void
184}
185
186; GCN-LABEL: @srem_i3(
187; SI: %r = srem i3 %a, %b
188; SI-NEXT: store volatile i3 %r
189; VI: %[[A_32:[0-9]+]] = sext i3 %a to i32
190; VI-NEXT: %[[B_32:[0-9]+]] = sext i3 %b to i32
191; VI-NEXT: %[[R_32:[0-9]+]] = srem i32 %[[A_32]], %[[B_32]]
192; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
193; VI-NEXT: store volatile i3 %[[R_3]]
194define amdgpu_kernel void @srem_i3(i3 %a, i3 %b) {
195  %r = srem i3 %a, %b
196  store volatile i3 %r, i3 addrspace(1)* undef
197  ret void
198}
199
200; GCN-LABEL: @shl_i3(
201; SI: %r = shl i3 %a, %b
202; SI-NEXT: store volatile i3 %r
203; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
204; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
205; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
206; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
207; VI-NEXT: store volatile i3 %[[R_3]]
208define amdgpu_kernel void @shl_i3(i3 %a, i3 %b) {
209  %r = shl i3 %a, %b
210  store volatile i3 %r, i3 addrspace(1)* undef
211  ret void
212}
213
214; GCN-LABEL: @shl_nsw_i3(
215; SI: %r = shl nsw i3 %a, %b
216; SI-NEXT: store volatile i3 %r
217; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
218; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
219; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
220; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
221; VI-NEXT: store volatile i3 %[[R_3]]
222define amdgpu_kernel void @shl_nsw_i3(i3 %a, i3 %b) {
223  %r = shl nsw i3 %a, %b
224  store volatile i3 %r, i3 addrspace(1)* undef
225  ret void
226}
227
228; GCN-LABEL: @shl_nuw_i3(
229; SI: %r = shl nuw i3 %a, %b
230; SI-NEXT: store volatile i3 %r
231; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
232; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
233; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
234; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
235; VI-NEXT: store volatile i3 %[[R_3]]
236define amdgpu_kernel void @shl_nuw_i3(i3 %a, i3 %b) {
237  %r = shl nuw i3 %a, %b
238  store volatile i3 %r, i3 addrspace(1)* undef
239  ret void
240}
241
242; GCN-LABEL: @shl_nuw_nsw_i3(
243; SI: %r = shl nuw nsw i3 %a, %b
244; SI-NEXT: store volatile i3 %r
245; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
246; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
247; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
248; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
249; VI-NEXT: store volatile i3 %[[R_3]]
250define amdgpu_kernel void @shl_nuw_nsw_i3(i3 %a, i3 %b) {
251  %r = shl nuw nsw i3 %a, %b
252  store volatile i3 %r, i3 addrspace(1)* undef
253  ret void
254}
255
256; GCN-LABEL: @lshr_i3(
257; SI: %r = lshr i3 %a, %b
258; SI-NEXT: store volatile i3 %r
259; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
260; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
261; VI-NEXT: %[[R_32:[0-9]+]] = lshr i32 %[[A_32]], %[[B_32]]
262; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
263; VI-NEXT: store volatile i3 %[[R_3]]
264define amdgpu_kernel void @lshr_i3(i3 %a, i3 %b) {
265  %r = lshr i3 %a, %b
266  store volatile i3 %r, i3 addrspace(1)* undef
267  ret void
268}
269
270; GCN-LABEL: @lshr_exact_i3(
271; SI: %r = lshr exact i3 %a, %b
272; SI-NEXT: store volatile i3 %r
273; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
274; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
275; VI-NEXT: %[[R_32:[0-9]+]] = lshr exact i32 %[[A_32]], %[[B_32]]
276; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
277; VI-NEXT: store volatile i3 %[[R_3]]
278define amdgpu_kernel void @lshr_exact_i3(i3 %a, i3 %b) {
279  %r = lshr exact i3 %a, %b
280  store volatile i3 %r, i3 addrspace(1)* undef
281  ret void
282}
283
284; GCN-LABEL: @ashr_i3(
285; SI: %r = ashr i3 %a, %b
286; SI-NEXT: store volatile i3 %r
287; VI: %[[A_32:[0-9]+]] = sext i3 %a to i32
288; VI-NEXT: %[[B_32:[0-9]+]] = sext i3 %b to i32
289; VI-NEXT: %[[R_32:[0-9]+]] = ashr i32 %[[A_32]], %[[B_32]]
290; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
291; VI-NEXT: store volatile i3 %[[R_3]]
292define amdgpu_kernel void @ashr_i3(i3 %a, i3 %b) {
293  %r = ashr i3 %a, %b
294  store volatile i3 %r, i3 addrspace(1)* undef
295  ret void
296}
297
298; GCN-LABEL: @ashr_exact_i3(
299; SI: %r = ashr exact i3 %a, %b
300; SI-NEXT: store volatile i3 %r
301; VI: %[[A_32:[0-9]+]] = sext i3 %a to i32
302; VI-NEXT: %[[B_32:[0-9]+]] = sext i3 %b to i32
303; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact i32 %[[A_32]], %[[B_32]]
304; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
305; VI-NEXT: store volatile i3 %[[R_3]]
306define amdgpu_kernel void @ashr_exact_i3(i3 %a, i3 %b) {
307  %r = ashr exact i3 %a, %b
308  store volatile i3 %r, i3 addrspace(1)* undef
309  ret void
310}
311
312; GCN-LABEL: @and_i3(
313; SI: %r = and i3 %a, %b
314; SI-NEXT: store volatile i3 %r
315; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
316; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
317; VI-NEXT: %[[R_32:[0-9]+]] = and i32 %[[A_32]], %[[B_32]]
318; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
319; VI-NEXT: store volatile i3 %[[R_3]]
320define amdgpu_kernel void @and_i3(i3 %a, i3 %b) {
321  %r = and i3 %a, %b
322  store volatile i3 %r, i3 addrspace(1)* undef
323  ret void
324}
325
326; GCN-LABEL: @or_i3(
327; SI: %r = or i3 %a, %b
328; SI-NEXT: store volatile i3 %r
329; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
330; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
331; VI-NEXT: %[[R_32:[0-9]+]] = or i32 %[[A_32]], %[[B_32]]
332; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
333; VI-NEXT: store volatile i3 %[[R_3]]
334define amdgpu_kernel void @or_i3(i3 %a, i3 %b) {
335  %r = or i3 %a, %b
336  store volatile i3 %r, i3 addrspace(1)* undef
337  ret void
338}
339
340; GCN-LABEL: @xor_i3(
341; SI: %r = xor i3 %a, %b
342; SI-NEXT: store volatile i3 %r
343; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
344; VI-NEXT: %[[B_32:[0-9]+]] = zext i3 %b to i32
345; VI-NEXT: %[[R_32:[0-9]+]] = xor i32 %[[A_32]], %[[B_32]]
346; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[R_32]] to i3
347; VI-NEXT: store volatile i3 %[[R_3]]
348define amdgpu_kernel void @xor_i3(i3 %a, i3 %b) {
349  %r = xor i3 %a, %b
350  store volatile i3 %r, i3 addrspace(1)* undef
351  ret void
352}
353
354; GCN-LABEL: @select_eq_i3(
355; SI: %cmp = icmp eq i3 %a, %b
356; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
357; SI-NEXT: store volatile i3 %sel
358; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
359; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
360; VI-NEXT: %[[CMP:[0-9]+]] = icmp eq i32 %[[A_32_0]], %[[B_32_0]]
361; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
362; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
363; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
364; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
365; VI-NEXT: store volatile i3 %[[SEL_3]]
366define amdgpu_kernel void @select_eq_i3(i3 %a, i3 %b) {
367  %cmp = icmp eq i3 %a, %b
368  %sel = select i1 %cmp, i3 %a, i3 %b
369  store volatile i3 %sel, i3 addrspace(1)* undef
370  ret void
371}
372
373; GCN-LABEL: @select_ne_i3(
374; SI: %cmp = icmp ne i3 %a, %b
375; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
376; SI-NEXT: store volatile i3 %sel
377; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
378; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
379; VI-NEXT: %[[CMP:[0-9]+]] = icmp ne i32 %[[A_32_0]], %[[B_32_0]]
380; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
381; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
382; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
383; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
384; VI-NEXT: store volatile i3 %[[SEL_3]]
385define amdgpu_kernel void @select_ne_i3(i3 %a, i3 %b) {
386  %cmp = icmp ne i3 %a, %b
387  %sel = select i1 %cmp, i3 %a, i3 %b
388  store volatile i3 %sel, i3 addrspace(1)* undef
389  ret void
390}
391
392; GCN-LABEL: @select_ugt_i3(
393; SI: %cmp = icmp ugt i3 %a, %b
394; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
395; SI-NEXT: store volatile i3 %sel
396; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
397; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
398; VI-NEXT: %[[CMP:[0-9]+]] = icmp ugt i32 %[[A_32_0]], %[[B_32_0]]
399; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
400; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
401; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
402; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
403; VI-NEXT: store volatile i3 %[[SEL_3]]
404define amdgpu_kernel void @select_ugt_i3(i3 %a, i3 %b) {
405  %cmp = icmp ugt i3 %a, %b
406  %sel = select i1 %cmp, i3 %a, i3 %b
407  store volatile i3 %sel, i3 addrspace(1)* undef
408  ret void
409}
410
411; GCN-LABEL: @select_uge_i3(
412; SI: %cmp = icmp uge i3 %a, %b
413; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
414; SI-NEXT: store volatile i3 %sel
415; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
416; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
417; VI-NEXT: %[[CMP:[0-9]+]] = icmp uge i32 %[[A_32_0]], %[[B_32_0]]
418; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
419; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
420; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
421; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
422; VI-NEXT: store volatile i3 %[[SEL_3]]
423define amdgpu_kernel void @select_uge_i3(i3 %a, i3 %b) {
424  %cmp = icmp uge i3 %a, %b
425  %sel = select i1 %cmp, i3 %a, i3 %b
426  store volatile i3 %sel, i3 addrspace(1)* undef
427  ret void
428}
429
430; GCN-LABEL: @select_ult_i3(
431; SI: %cmp = icmp ult i3 %a, %b
432; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
433; SI-NEXT: store volatile i3 %sel
434; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
435; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
436; VI-NEXT: %[[CMP:[0-9]+]] = icmp ult i32 %[[A_32_0]], %[[B_32_0]]
437; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
438; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
439; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
440; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
441; VI-NEXT: store volatile i3 %[[SEL_3]]
442define amdgpu_kernel void @select_ult_i3(i3 %a, i3 %b) {
443  %cmp = icmp ult i3 %a, %b
444  %sel = select i1 %cmp, i3 %a, i3 %b
445  store volatile i3 %sel, i3 addrspace(1)* undef
446  ret void
447}
448
449; GCN-LABEL: @select_ule_i3(
450; SI: %cmp = icmp ule i3 %a, %b
451; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
452; SI-NEXT: store volatile i3 %sel
453; VI: %[[A_32_0:[0-9]+]] = zext i3 %a to i32
454; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i3 %b to i32
455; VI-NEXT: %[[CMP:[0-9]+]] = icmp ule i32 %[[A_32_0]], %[[B_32_0]]
456; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i3 %a to i32
457; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i3 %b to i32
458; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
459; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
460; VI-NEXT: store volatile i3 %[[SEL_3]]
461define amdgpu_kernel void @select_ule_i3(i3 %a, i3 %b) {
462  %cmp = icmp ule i3 %a, %b
463  %sel = select i1 %cmp, i3 %a, i3 %b
464  store volatile i3 %sel, i3 addrspace(1)* undef
465  ret void
466}
467
468; GCN-LABEL: @select_sgt_i3(
469; SI: %cmp = icmp sgt i3 %a, %b
470; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
471; SI-NEXT: store volatile i3 %sel
472; VI: %[[A_32_0:[0-9]+]] = sext i3 %a to i32
473; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i3 %b to i32
474; VI-NEXT: %[[CMP:[0-9]+]] = icmp sgt i32 %[[A_32_0]], %[[B_32_0]]
475; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i3 %a to i32
476; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i3 %b to i32
477; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
478; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
479; VI-NEXT: store volatile i3 %[[SEL_3]]
480define amdgpu_kernel void @select_sgt_i3(i3 %a, i3 %b) {
481  %cmp = icmp sgt i3 %a, %b
482  %sel = select i1 %cmp, i3 %a, i3 %b
483  store volatile i3 %sel, i3 addrspace(1)* undef
484  ret void
485}
486
487; GCN-LABEL: @select_sge_i3(
488; SI: %cmp = icmp sge i3 %a, %b
489; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
490; SI-NEXT: store volatile i3 %sel
491; VI: %[[A_32_0:[0-9]+]] = sext i3 %a to i32
492; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i3 %b to i32
493; VI-NEXT: %[[CMP:[0-9]+]] = icmp sge i32 %[[A_32_0]], %[[B_32_0]]
494; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i3 %a to i32
495; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i3 %b to i32
496; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
497; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
498; VI-NEXT: store volatile i3 %[[SEL_3]]
499define amdgpu_kernel void @select_sge_i3(i3 %a, i3 %b) {
500  %cmp = icmp sge i3 %a, %b
501  %sel = select i1 %cmp, i3 %a, i3 %b
502  store volatile i3 %sel, i3 addrspace(1)* undef
503  ret void
504}
505
506; GCN-LABEL: @select_slt_i3(
507; SI: %cmp = icmp slt i3 %a, %b
508; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
509; SI-NEXT: store volatile i3 %sel
510; VI: %[[A_32_0:[0-9]+]] = sext i3 %a to i32
511; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i3 %b to i32
512; VI-NEXT: %[[CMP:[0-9]+]] = icmp slt i32 %[[A_32_0]], %[[B_32_0]]
513; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i3 %a to i32
514; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i3 %b to i32
515; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
516; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
517; VI-NEXT: store volatile i3 %[[SEL_3]]
518define amdgpu_kernel void @select_slt_i3(i3 %a, i3 %b) {
519  %cmp = icmp slt i3 %a, %b
520  %sel = select i1 %cmp, i3 %a, i3 %b
521  store volatile i3 %sel, i3 addrspace(1)* undef
522  ret void
523}
524
525; GCN-LABEL: @select_sle_i3(
526; SI: %cmp = icmp sle i3 %a, %b
527; SI-NEXT: %sel = select i1 %cmp, i3 %a, i3 %b
528; SI-NEXT: store volatile i3 %sel
529; VI: %[[A_32_0:[0-9]+]] = sext i3 %a to i32
530; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i3 %b to i32
531; VI-NEXT: %[[CMP:[0-9]+]] = icmp sle i32 %[[A_32_0]], %[[B_32_0]]
532; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i3 %a to i32
533; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i3 %b to i32
534; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
535; VI-NEXT: %[[SEL_3:[0-9]+]] = trunc i32 %[[SEL_32]] to i3
536; VI-NEXT: store volatile i3 %[[SEL_3]]
537define amdgpu_kernel void @select_sle_i3(i3 %a, i3 %b) {
538  %cmp = icmp sle i3 %a, %b
539  %sel = select i1 %cmp, i3 %a, i3 %b
540  store volatile i3 %sel, i3 addrspace(1)* undef
541  ret void
542}
543
544declare i3 @llvm.bitreverse.i3(i3)
545; GCN-LABEL: @bitreverse_i3(
546; SI: %brev = call i3 @llvm.bitreverse.i3(i3 %a)
547; SI-NEXT: store volatile i3 %brev
548; VI: %[[A_32:[0-9]+]] = zext i3 %a to i32
549; VI-NEXT: %[[R_32:[0-9]+]] = call i32 @llvm.bitreverse.i32(i32 %[[A_32]])
550; VI-NEXT: %[[S_32:[0-9]+]] = lshr i32 %[[R_32]], 29
551; VI-NEXT: %[[R_3:[0-9]+]] = trunc i32 %[[S_32]] to i3
552; VI-NEXT: store volatile i3 %[[R_3]]
553define amdgpu_kernel void @bitreverse_i3(i3 %a) {
554  %brev = call i3 @llvm.bitreverse.i3(i3 %a)
555  store volatile i3 %brev, i3 addrspace(1)* undef
556  ret void
557}
558
559; GCN-LABEL: @add_i16(
560; SI: %r = add i16 %a, %b
561; SI-NEXT: store volatile i16 %r
562; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
563; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
564; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
565; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
566; VI-NEXT: store volatile i16 %[[R_16]]
567define amdgpu_kernel void @add_i16(i16 %a, i16 %b) {
568  %r = add i16 %a, %b
569  store volatile i16 %r, i16 addrspace(1)* undef
570  ret void
571}
572
573; GCN-LABEL: @constant_add_i16(
574; VI: store volatile i16 3
575define amdgpu_kernel void @constant_add_i16() {
576  %r = add i16 1, 2
577  store volatile i16 %r, i16 addrspace(1)* undef
578  ret void
579}
580
581; GCN-LABEL: @constant_add_nsw_i16(
582; VI: store volatile i16 3
583define amdgpu_kernel void @constant_add_nsw_i16() {
584  %r = add nsw i16 1, 2
585  store volatile i16 %r, i16 addrspace(1)* undef
586  ret void
587}
588
589; GCN-LABEL: @constant_add_nuw_i16(
590; VI: store volatile i16 3
591define amdgpu_kernel void @constant_add_nuw_i16() {
592  %r = add nsw i16 1, 2
593  store volatile i16 %r, i16 addrspace(1)* undef
594  ret void
595}
596
597; GCN-LABEL: @add_nsw_i16(
598; SI: %r = add nsw i16 %a, %b
599; SI-NEXT: store volatile i16 %r
600; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
601; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
602; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
603; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
604; VI-NEXT: store volatile i16 %[[R_16]]
605define amdgpu_kernel void @add_nsw_i16(i16 %a, i16 %b) {
606  %r = add nsw i16 %a, %b
607  store volatile i16 %r, i16 addrspace(1)* undef
608  ret void
609}
610
611; GCN-LABEL: @add_nuw_i16(
612; SI: %r = add nuw i16 %a, %b
613; SI-NEXT: store volatile i16 %r
614; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
615; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
616; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
617; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
618; VI-NEXT: store volatile i16 %[[R_16]]
619define amdgpu_kernel void @add_nuw_i16(i16 %a, i16 %b) {
620  %r = add nuw i16 %a, %b
621  store volatile i16 %r, i16 addrspace(1)* undef
622  ret void
623}
624
625; GCN-LABEL: @add_nuw_nsw_i16(
626; SI: %r = add nuw nsw i16 %a, %b
627; SI-NEXT: store volatile i16 %r
628; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
629; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
630; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw i32 %[[A_32]], %[[B_32]]
631; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
632; VI-NEXT: store volatile i16 %[[R_16]]
633define amdgpu_kernel void @add_nuw_nsw_i16(i16 %a, i16 %b) {
634  %r = add nuw nsw i16 %a, %b
635  store volatile i16 %r, i16 addrspace(1)* undef
636  ret void
637}
638
639; GCN-LABEL: @sub_i16(
640; SI: %r = sub i16 %a, %b
641; SI-NEXT: store volatile i16 %r
642; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
643; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
644; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw i32 %[[A_32]], %[[B_32]]
645; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
646; VI-NEXT: store volatile i16 %[[R_16]]
647define amdgpu_kernel void @sub_i16(i16 %a, i16 %b) {
648  %r = sub i16 %a, %b
649  store volatile i16 %r, i16 addrspace(1)* undef
650  ret void
651}
652
653; GCN-LABEL: @sub_nsw_i16(
654; SI: %r = sub nsw i16 %a, %b
655; SI-NEXT: store volatile i16 %r
656; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
657; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
658; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw i32 %[[A_32]], %[[B_32]]
659; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
660; VI-NEXT: store volatile i16 %[[R_16]]
661define amdgpu_kernel void @sub_nsw_i16(i16 %a, i16 %b) {
662  %r = sub nsw i16 %a, %b
663  store volatile i16 %r, i16 addrspace(1)* undef
664  ret void
665}
666
667; GCN-LABEL: @sub_nuw_i16(
668; SI: %r = sub nuw i16 %a, %b
669; SI-NEXT: store volatile i16 %r
670; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
671; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
672; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw i32 %[[A_32]], %[[B_32]]
673; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
674; VI-NEXT: store volatile i16 %[[R_16]]
675define amdgpu_kernel void @sub_nuw_i16(i16 %a, i16 %b) {
676  %r = sub nuw i16 %a, %b
677  store volatile i16 %r, i16 addrspace(1)* undef
678  ret void
679}
680
681; GCN-LABEL: @sub_nuw_nsw_i16(
682; SI: %r = sub nuw nsw i16 %a, %b
683; SI-NEXT: store volatile i16 %r
684; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
685; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
686; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw i32 %[[A_32]], %[[B_32]]
687; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
688; VI-NEXT: store volatile i16 %[[R_16]]
689define amdgpu_kernel void @sub_nuw_nsw_i16(i16 %a, i16 %b) {
690  %r = sub nuw nsw i16 %a, %b
691  store volatile i16 %r, i16 addrspace(1)* undef
692  ret void
693}
694
695; GCN-LABEL: @mul_i16(
696; SI: %r = mul i16 %a, %b
697; SI-NEXT: store volatile i16 %r
698; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
699; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
700; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw i32 %[[A_32]], %[[B_32]]
701; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
702; VI-NEXT: store volatile i16 %[[R_16]]
703define amdgpu_kernel void @mul_i16(i16 %a, i16 %b) {
704  %r = mul i16 %a, %b
705  store volatile i16 %r, i16 addrspace(1)* undef
706  ret void
707}
708
709; GCN-LABEL: @mul_nsw_i16(
710; SI: %r = mul nsw i16 %a, %b
711; SI-NEXT: store volatile i16 %r
712; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
713; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
714; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw i32 %[[A_32]], %[[B_32]]
715; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
716; VI-NEXT: store volatile i16 %[[R_16]]
717define amdgpu_kernel void @mul_nsw_i16(i16 %a, i16 %b) {
718  %r = mul nsw i16 %a, %b
719  store volatile i16 %r, i16 addrspace(1)* undef
720  ret void
721}
722
723; GCN-LABEL: @mul_nuw_i16(
724; SI: %r = mul nuw i16 %a, %b
725; SI-NEXT: store volatile i16 %r
726; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
727; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
728; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw i32 %[[A_32]], %[[B_32]]
729; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
730; VI-NEXT: store volatile i16 %[[R_16]]
731define amdgpu_kernel void @mul_nuw_i16(i16 %a, i16 %b) {
732  %r = mul nuw i16 %a, %b
733  store volatile i16 %r, i16 addrspace(1)* undef
734  ret void
735}
736
737; GCN-LABEL: @mul_nuw_nsw_i16(
738; SI: %r = mul nuw nsw i16 %a, %b
739; SI-NEXT: store volatile i16 %r
740; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
741; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
742; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw i32 %[[A_32]], %[[B_32]]
743; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
744; VI-NEXT: store volatile i16 %[[R_16]]
745define amdgpu_kernel void @mul_nuw_nsw_i16(i16 %a, i16 %b) {
746  %r = mul nuw nsw i16 %a, %b
747  store volatile i16 %r, i16 addrspace(1)* undef
748  ret void
749}
750
751; GCN-LABEL: @urem_i16(
752; SI: %r = urem i16 %a, %b
753; SI-NEXT: store volatile i16 %r
754; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
755; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
756; VI-NEXT: %[[R_32:[0-9]+]] = urem i32 %[[A_32]], %[[B_32]]
757; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
758; VI-NEXT: store volatile i16 %[[R_16]]
759define amdgpu_kernel void @urem_i16(i16 %a, i16 %b) {
760  %r = urem i16 %a, %b
761  store volatile i16 %r, i16 addrspace(1)* undef
762  ret void
763}
764
765; GCN-LABEL: @srem_i16(
766; SI: %r = srem i16 %a, %b
767; SI-NEXT: store volatile i16 %r
768; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32
769; VI-NEXT: %[[B_32:[0-9]+]] = sext i16 %b to i32
770; VI-NEXT: %[[R_32:[0-9]+]] = srem i32 %[[A_32]], %[[B_32]]
771; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
772; VI-NEXT: store volatile i16 %[[R_16]]
773define amdgpu_kernel void @srem_i16(i16 %a, i16 %b) {
774  %r = srem i16 %a, %b
775  store volatile i16 %r, i16 addrspace(1)* undef
776  ret void
777}
778
779; GCN-LABEL: @shl_i16(
780; SI: %r = shl i16 %a, %b
781; SI-NEXT: store volatile i16 %r
782; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
783; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
784; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
785; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
786; VI-NEXT: store volatile i16 %[[R_16]]
787define amdgpu_kernel void @shl_i16(i16 %a, i16 %b) {
788  %r = shl i16 %a, %b
789  store volatile i16 %r, i16 addrspace(1)* undef
790  ret void
791}
792
793; GCN-LABEL: @shl_nsw_i16(
794; SI: %r = shl nsw i16 %a, %b
795; SI-NEXT: store volatile i16 %r
796; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
797; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
798; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
799; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
800; VI-NEXT: store volatile i16 %[[R_16]]
801define amdgpu_kernel void @shl_nsw_i16(i16 %a, i16 %b) {
802  %r = shl nsw i16 %a, %b
803  store volatile i16 %r, i16 addrspace(1)* undef
804  ret void
805}
806
807; GCN-LABEL: @shl_nuw_i16(
808; SI: %r = shl nuw i16 %a, %b
809; SI-NEXT: store volatile i16 %r
810; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
811; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
812; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
813; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
814; VI-NEXT: store volatile i16 %[[R_16]]
815define amdgpu_kernel void @shl_nuw_i16(i16 %a, i16 %b) {
816  %r = shl nuw i16 %a, %b
817  store volatile i16 %r, i16 addrspace(1)* undef
818  ret void
819}
820
821; GCN-LABEL: @shl_nuw_nsw_i16(
822; SI: %r = shl nuw nsw i16 %a, %b
823; SI-NEXT: store volatile i16 %r
824; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
825; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
826; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw i32 %[[A_32]], %[[B_32]]
827; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
828; VI-NEXT: store volatile i16 %[[R_16]]
829define amdgpu_kernel void @shl_nuw_nsw_i16(i16 %a, i16 %b) {
830  %r = shl nuw nsw i16 %a, %b
831  store volatile i16 %r, i16 addrspace(1)* undef
832  ret void
833}
834
835; GCN-LABEL: @lshr_i16(
836; SI: %r = lshr i16 %a, %b
837; SI-NEXT: store volatile i16 %r
838; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
839; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
840; VI-NEXT: %[[R_32:[0-9]+]] = lshr i32 %[[A_32]], %[[B_32]]
841; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
842; VI-NEXT: store volatile i16 %[[R_16]]
843define amdgpu_kernel void @lshr_i16(i16 %a, i16 %b) {
844  %r = lshr i16 %a, %b
845  store volatile i16 %r, i16 addrspace(1)* undef
846  ret void
847}
848
849; GCN-LABEL: @lshr_exact_i16(
850; SI: %r = lshr exact i16 %a, %b
851; SI-NEXT: store volatile i16 %r
852; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
853; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
854; VI-NEXT: %[[R_32:[0-9]+]] = lshr exact i32 %[[A_32]], %[[B_32]]
855; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
856; VI-NEXT: store volatile i16 %[[R_16]]
857define amdgpu_kernel void @lshr_exact_i16(i16 %a, i16 %b) {
858  %r = lshr exact i16 %a, %b
859  store volatile i16 %r, i16 addrspace(1)* undef
860  ret void
861}
862
863; GCN-LABEL: @ashr_i16(
864; SI: %r = ashr i16 %a, %b
865; SI-NEXT: store volatile i16 %r
866; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32
867; VI-NEXT: %[[B_32:[0-9]+]] = sext i16 %b to i32
868; VI-NEXT: %[[R_32:[0-9]+]] = ashr i32 %[[A_32]], %[[B_32]]
869; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
870; VI-NEXT: store volatile i16 %[[R_16]]
871define amdgpu_kernel void @ashr_i16(i16 %a, i16 %b) {
872  %r = ashr i16 %a, %b
873  store volatile i16 %r, i16 addrspace(1)* undef
874  ret void
875}
876
877; GCN-LABEL: @ashr_exact_i16(
878; SI: %r = ashr exact i16 %a, %b
879; SI-NEXT: store volatile i16 %r
880; VI: %[[A_32:[0-9]+]] = sext i16 %a to i32
881; VI-NEXT: %[[B_32:[0-9]+]] = sext i16 %b to i32
882; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact i32 %[[A_32]], %[[B_32]]
883; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
884; VI-NEXT: store volatile i16 %[[R_16]]
885define amdgpu_kernel void @ashr_exact_i16(i16 %a, i16 %b) {
886  %r = ashr exact i16 %a, %b
887  store volatile i16 %r, i16 addrspace(1)* undef
888  ret void
889}
890
891; GCN-LABEL: @constant_lshr_exact_i16(
892; VI: store volatile i16 2
893define amdgpu_kernel void @constant_lshr_exact_i16(i16 %a, i16 %b) {
894  %r = lshr exact i16 4, 1
895  store volatile i16 %r, i16 addrspace(1)* undef
896  ret void
897}
898
899; GCN-LABEL: @and_i16(
900; SI: %r = and i16 %a, %b
901; SI-NEXT: store volatile i16 %r
902; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
903; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
904; VI-NEXT: %[[R_32:[0-9]+]] = and i32 %[[A_32]], %[[B_32]]
905; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
906; VI-NEXT: store volatile i16 %[[R_16]]
907define amdgpu_kernel void @and_i16(i16 %a, i16 %b) {
908  %r = and i16 %a, %b
909  store volatile i16 %r, i16 addrspace(1)* undef
910  ret void
911}
912
913; GCN-LABEL: @or_i16(
914; SI: %r = or i16 %a, %b
915; SI-NEXT: store volatile i16 %r
916; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
917; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
918; VI-NEXT: %[[R_32:[0-9]+]] = or i32 %[[A_32]], %[[B_32]]
919; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
920; VI-NEXT: store volatile i16 %[[R_16]]
921define amdgpu_kernel void @or_i16(i16 %a, i16 %b) {
922  %r = or i16 %a, %b
923  store volatile i16 %r, i16 addrspace(1)* undef
924  ret void
925}
926
927; GCN-LABEL: @xor_i16(
928; SI: %r = xor i16 %a, %b
929; SI-NEXT: store volatile i16 %r
930; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
931; VI-NEXT: %[[B_32:[0-9]+]] = zext i16 %b to i32
932; VI-NEXT: %[[R_32:[0-9]+]] = xor i32 %[[A_32]], %[[B_32]]
933; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[R_32]] to i16
934; VI-NEXT: store volatile i16 %[[R_16]]
935define amdgpu_kernel void @xor_i16(i16 %a, i16 %b) {
936  %r = xor i16 %a, %b
937  store volatile i16 %r, i16 addrspace(1)* undef
938  ret void
939}
940
941; GCN-LABEL: @select_eq_i16(
942; SI: %cmp = icmp eq i16 %a, %b
943; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
944; SI-NEXT: store volatile i16 %sel
945; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
946; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
947; VI-NEXT: %[[CMP:[0-9]+]] = icmp eq i32 %[[A_32_0]], %[[B_32_0]]
948; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
949; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
950; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
951; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
952; VI-NEXT: store volatile i16 %[[SEL_16]]
953define amdgpu_kernel void @select_eq_i16(i16 %a, i16 %b) {
954  %cmp = icmp eq i16 %a, %b
955  %sel = select i1 %cmp, i16 %a, i16 %b
956  store volatile i16 %sel, i16 addrspace(1)* undef
957  ret void
958}
959
960; GCN-LABEL: @select_ne_i16(
961; SI: %cmp = icmp ne i16 %a, %b
962; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
963; SI-NEXT: store volatile i16 %sel
964; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
965; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
966; VI-NEXT: %[[CMP:[0-9]+]] = icmp ne i32 %[[A_32_0]], %[[B_32_0]]
967; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
968; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
969; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
970; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
971; VI-NEXT: store volatile i16 %[[SEL_16]]
972define amdgpu_kernel void @select_ne_i16(i16 %a, i16 %b) {
973  %cmp = icmp ne i16 %a, %b
974  %sel = select i1 %cmp, i16 %a, i16 %b
975  store volatile i16 %sel, i16 addrspace(1)* undef
976  ret void
977}
978
979; GCN-LABEL: @select_ugt_i16(
980; SI: %cmp = icmp ugt i16 %a, %b
981; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
982; SI-NEXT: store volatile i16 %sel
983; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
984; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
985; VI-NEXT: %[[CMP:[0-9]+]] = icmp ugt i32 %[[A_32_0]], %[[B_32_0]]
986; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
987; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
988; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
989; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
990; VI-NEXT: store volatile i16 %[[SEL_16]]
991define amdgpu_kernel void @select_ugt_i16(i16 %a, i16 %b) {
992  %cmp = icmp ugt i16 %a, %b
993  %sel = select i1 %cmp, i16 %a, i16 %b
994  store volatile i16 %sel, i16 addrspace(1)* undef
995  ret void
996}
997
998; GCN-LABEL: @select_uge_i16(
999; SI: %cmp = icmp uge i16 %a, %b
1000; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1001; SI-NEXT: store volatile i16 %sel
1002; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
1003; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
1004; VI-NEXT: %[[CMP:[0-9]+]] = icmp uge i32 %[[A_32_0]], %[[B_32_0]]
1005; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
1006; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
1007; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1008; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1009; VI-NEXT: store volatile i16 %[[SEL_16]]
1010define amdgpu_kernel void @select_uge_i16(i16 %a, i16 %b) {
1011  %cmp = icmp uge i16 %a, %b
1012  %sel = select i1 %cmp, i16 %a, i16 %b
1013  store volatile i16 %sel, i16 addrspace(1)* undef
1014  ret void
1015}
1016
1017; GCN-LABEL: @select_ult_i16(
1018; SI: %cmp = icmp ult i16 %a, %b
1019; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1020; SI-NEXT: store volatile i16 %sel
1021; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
1022; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
1023; VI-NEXT: %[[CMP:[0-9]+]] = icmp ult i32 %[[A_32_0]], %[[B_32_0]]
1024; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
1025; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
1026; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1027; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1028; VI-NEXT: store volatile i16 %[[SEL_16]]
1029define amdgpu_kernel void @select_ult_i16(i16 %a, i16 %b) {
1030  %cmp = icmp ult i16 %a, %b
1031  %sel = select i1 %cmp, i16 %a, i16 %b
1032  store volatile i16 %sel, i16 addrspace(1)* undef
1033  ret void
1034}
1035
1036; GCN-LABEL: @select_ule_i16(
1037; SI: %cmp = icmp ule i16 %a, %b
1038; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1039; SI-NEXT: store volatile i16 %sel
1040; VI: %[[A_32_0:[0-9]+]] = zext i16 %a to i32
1041; VI-NEXT: %[[B_32_0:[0-9]+]] = zext i16 %b to i32
1042; VI-NEXT: %[[CMP:[0-9]+]] = icmp ule i32 %[[A_32_0]], %[[B_32_0]]
1043; VI-NEXT: %[[A_32_1:[0-9]+]] = zext i16 %a to i32
1044; VI-NEXT: %[[B_32_1:[0-9]+]] = zext i16 %b to i32
1045; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1046; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1047; VI-NEXT: store volatile i16 %[[SEL_16]]
1048define amdgpu_kernel void @select_ule_i16(i16 %a, i16 %b) {
1049  %cmp = icmp ule i16 %a, %b
1050  %sel = select i1 %cmp, i16 %a, i16 %b
1051  store volatile i16 %sel, i16 addrspace(1)* undef
1052  ret void
1053}
1054
1055; GCN-LABEL: @select_sgt_i16(
1056; SI: %cmp = icmp sgt i16 %a, %b
1057; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1058; SI-NEXT: store volatile i16 %sel
1059; VI: %[[A_32_0:[0-9]+]] = sext i16 %a to i32
1060; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i16 %b to i32
1061; VI-NEXT: %[[CMP:[0-9]+]] = icmp sgt i32 %[[A_32_0]], %[[B_32_0]]
1062; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i16 %a to i32
1063; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i16 %b to i32
1064; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1065; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1066; VI-NEXT: store volatile i16 %[[SEL_16]]
1067define amdgpu_kernel void @select_sgt_i16(i16 %a, i16 %b) {
1068  %cmp = icmp sgt i16 %a, %b
1069  %sel = select i1 %cmp, i16 %a, i16 %b
1070  store volatile i16 %sel, i16 addrspace(1)* undef
1071  ret void
1072}
1073
1074; GCN-LABEL: @select_sge_i16(
1075; SI: %cmp = icmp sge i16 %a, %b
1076; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1077; SI-NEXT: store volatile i16 %sel
1078; VI: %[[A_32_0:[0-9]+]] = sext i16 %a to i32
1079; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i16 %b to i32
1080; VI-NEXT: %[[CMP:[0-9]+]] = icmp sge i32 %[[A_32_0]], %[[B_32_0]]
1081; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i16 %a to i32
1082; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i16 %b to i32
1083; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1084; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1085; VI-NEXT: store volatile i16 %[[SEL_16]]
1086define amdgpu_kernel void @select_sge_i16(i16 %a, i16 %b) {
1087  %cmp = icmp sge i16 %a, %b
1088  %sel = select i1 %cmp, i16 %a, i16 %b
1089  store volatile i16 %sel, i16 addrspace(1)* undef
1090  ret void
1091}
1092
1093; GCN-LABEL: @select_slt_i16(
1094; SI: %cmp = icmp slt i16 %a, %b
1095; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1096; SI-NEXT: store volatile i16 %sel
1097; VI: %[[A_32_0:[0-9]+]] = sext i16 %a to i32
1098; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i16 %b to i32
1099; VI-NEXT: %[[CMP:[0-9]+]] = icmp slt i32 %[[A_32_0]], %[[B_32_0]]
1100; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i16 %a to i32
1101; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i16 %b to i32
1102; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1103; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1104; VI-NEXT: store volatile i16 %[[SEL_16]]
1105define amdgpu_kernel void @select_slt_i16(i16 %a, i16 %b) {
1106  %cmp = icmp slt i16 %a, %b
1107  %sel = select i1 %cmp, i16 %a, i16 %b
1108  store volatile i16 %sel, i16 addrspace(1)* undef
1109  ret void
1110}
1111
1112; GCN-LABEL: @select_sle_i16(
1113; SI: %cmp = icmp sle i16 %a, %b
1114; SI-NEXT: %sel = select i1 %cmp, i16 %a, i16 %b
1115; SI-NEXT: store volatile i16 %sel
1116; VI: %[[A_32_0:[0-9]+]] = sext i16 %a to i32
1117; VI-NEXT: %[[B_32_0:[0-9]+]] = sext i16 %b to i32
1118; VI-NEXT: %[[CMP:[0-9]+]] = icmp sle i32 %[[A_32_0]], %[[B_32_0]]
1119; VI-NEXT: %[[A_32_1:[0-9]+]] = sext i16 %a to i32
1120; VI-NEXT: %[[B_32_1:[0-9]+]] = sext i16 %b to i32
1121; VI-NEXT: %[[SEL_32:[0-9]+]] = select i1 %[[CMP]], i32 %[[A_32_1]], i32 %[[B_32_1]]
1122; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc i32 %[[SEL_32]] to i16
1123; VI-NEXT: store volatile i16 %[[SEL_16]]
1124define amdgpu_kernel void @select_sle_i16(i16 %a, i16 %b) {
1125  %cmp = icmp sle i16 %a, %b
1126  %sel = select i1 %cmp, i16 %a, i16 %b
1127  store volatile i16 %sel, i16 addrspace(1)* undef
1128  ret void
1129}
1130
1131declare i16 @llvm.bitreverse.i16(i16)
1132
1133; GCN-LABEL: @bitreverse_i16(
1134; SI: %brev = call i16 @llvm.bitreverse.i16(i16 %a)
1135; SI-NEXT: store volatile i16 %brev
1136; VI: %[[A_32:[0-9]+]] = zext i16 %a to i32
1137; VI-NEXT: %[[R_32:[0-9]+]] = call i32 @llvm.bitreverse.i32(i32 %[[A_32]])
1138; VI-NEXT: %[[S_32:[0-9]+]] = lshr i32 %[[R_32]], 16
1139; VI-NEXT: %[[R_16:[0-9]+]] = trunc i32 %[[S_32]] to i16
1140; VI-NEXT: store volatile i16 %[[R_16]]
1141define amdgpu_kernel void @bitreverse_i16(i16 %a) {
1142  %brev = call i16 @llvm.bitreverse.i16(i16 %a)
1143  store volatile i16 %brev, i16 addrspace(1)* undef
1144  ret void
1145}
1146
1147; GCN-LABEL: @add_3xi15(
1148; SI: %r = add <3 x i15> %a, %b
1149; SI-NEXT: store volatile <3 x i15> %r
1150; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1151; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1152; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1153; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1154; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1155define amdgpu_kernel void @add_3xi15(<3 x i15> %a, <3 x i15> %b) {
1156  %r = add <3 x i15> %a, %b
1157  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1158  ret void
1159}
1160
1161; GCN-LABEL: @add_nsw_3xi15(
1162; SI: %r = add nsw <3 x i15> %a, %b
1163; SI-NEXT: store volatile <3 x i15> %r
1164; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1165; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1166; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1167; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1168; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1169define amdgpu_kernel void @add_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1170  %r = add nsw <3 x i15> %a, %b
1171  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1172  ret void
1173}
1174
1175; GCN-LABEL: @add_nuw_3xi15(
1176; SI: %r = add nuw <3 x i15> %a, %b
1177; SI-NEXT: store volatile <3 x i15> %r
1178; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1179; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1180; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1181; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1182; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1183define amdgpu_kernel void @add_nuw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1184  %r = add nuw <3 x i15> %a, %b
1185  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1186  ret void
1187}
1188
1189; GCN-LABEL: @add_nuw_nsw_3xi15(
1190; SI: %r = add nuw nsw <3 x i15> %a, %b
1191; SI-NEXT: store volatile <3 x i15> %r
1192; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1193; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1194; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1195; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1196; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1197define amdgpu_kernel void @add_nuw_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1198  %r = add nuw nsw <3 x i15> %a, %b
1199  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1200  ret void
1201}
1202
1203; GCN-LABEL: @sub_3xi15(
1204; SI: %r = sub <3 x i15> %a, %b
1205; SI-NEXT: store volatile <3 x i15> %r
1206; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1207; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1208; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw <3 x i32> %[[A_32]], %[[B_32]]
1209; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1210; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1211define amdgpu_kernel void @sub_3xi15(<3 x i15> %a, <3 x i15> %b) {
1212  %r = sub <3 x i15> %a, %b
1213  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1214  ret void
1215}
1216
1217; GCN-LABEL: @sub_nsw_3xi15(
1218; SI: %r = sub nsw <3 x i15> %a, %b
1219; SI-NEXT: store volatile <3 x i15> %r
1220; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1221; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1222; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw <3 x i32> %[[A_32]], %[[B_32]]
1223; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1224; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1225define amdgpu_kernel void @sub_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1226  %r = sub nsw <3 x i15> %a, %b
1227  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1228  ret void
1229}
1230
1231; GCN-LABEL: @sub_nuw_3xi15(
1232; SI: %r = sub nuw <3 x i15> %a, %b
1233; SI-NEXT: store volatile <3 x i15> %r
1234; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1235; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1236; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1237; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1238; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1239define amdgpu_kernel void @sub_nuw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1240  %r = sub nuw <3 x i15> %a, %b
1241  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1242  ret void
1243}
1244
1245; GCN-LABEL: @sub_nuw_nsw_3xi15(
1246; SI: %r = sub nuw nsw <3 x i15> %a, %b
1247; SI-NEXT: store volatile <3 x i15> %r
1248; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1249; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1250; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1251; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1252; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1253define amdgpu_kernel void @sub_nuw_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1254  %r = sub nuw nsw <3 x i15> %a, %b
1255  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1256  ret void
1257}
1258
1259; GCN-LABEL: @mul_3xi15(
1260; SI: %r = mul <3 x i15> %a, %b
1261; SI-NEXT: store volatile <3 x i15> %r
1262; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1263; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1264; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw <3 x i32> %[[A_32]], %[[B_32]]
1265; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1266; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1267define amdgpu_kernel void @mul_3xi15(<3 x i15> %a, <3 x i15> %b) {
1268  %r = mul <3 x i15> %a, %b
1269  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1270  ret void
1271}
1272
1273; GCN-LABEL: @mul_nsw_3xi15(
1274; SI: %r = mul nsw <3 x i15> %a, %b
1275; SI-NEXT: store volatile <3 x i15> %r
1276; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1277; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1278; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw <3 x i32> %[[A_32]], %[[B_32]]
1279; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1280; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1281define amdgpu_kernel void @mul_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1282  %r = mul nsw <3 x i15> %a, %b
1283  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1284  ret void
1285}
1286
1287; GCN-LABEL: @mul_nuw_3xi15(
1288; SI: %r = mul nuw <3 x i15> %a, %b
1289; SI-NEXT: store volatile <3 x i15> %r
1290; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1291; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1292; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1293; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1294; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1295define amdgpu_kernel void @mul_nuw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1296  %r = mul nuw <3 x i15> %a, %b
1297  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1298  ret void
1299}
1300
1301; GCN-LABEL: @mul_nuw_nsw_3xi15(
1302; SI: %r = mul nuw nsw <3 x i15> %a, %b
1303; SI-NEXT: store volatile <3 x i15> %r
1304; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1305; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1306; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1307; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1308; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1309define amdgpu_kernel void @mul_nuw_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1310  %r = mul nuw nsw <3 x i15> %a, %b
1311  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1312  ret void
1313}
1314
1315; GCN-LABEL: @urem_3xi15(
1316; SI: %r = urem <3 x i15> %a, %b
1317; SI-NEXT: store volatile <3 x i15> %r
1318; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1319; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1320; VI-NEXT: %[[R_32:[0-9]+]] = urem <3 x i32> %[[A_32]], %[[B_32]]
1321; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1322; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1323define amdgpu_kernel void @urem_3xi15(<3 x i15> %a, <3 x i15> %b) {
1324  %r = urem <3 x i15> %a, %b
1325  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1326  ret void
1327}
1328
1329; GCN-LABEL: @srem_3xi15(
1330; SI: %r = srem <3 x i15> %a, %b
1331; SI-NEXT: store volatile <3 x i15> %r
1332; VI: %[[A_32:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1333; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1334; VI-NEXT: %[[R_32:[0-9]+]] = srem <3 x i32> %[[A_32]], %[[B_32]]
1335; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1336; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1337define amdgpu_kernel void @srem_3xi15(<3 x i15> %a, <3 x i15> %b) {
1338  %r = srem <3 x i15> %a, %b
1339  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1340  ret void
1341}
1342
1343; GCN-LABEL: @shl_3xi15(
1344; SI: %r = shl <3 x i15> %a, %b
1345; SI-NEXT: store volatile <3 x i15> %r
1346; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1347; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1348; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1349; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1350; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1351define amdgpu_kernel void @shl_3xi15(<3 x i15> %a, <3 x i15> %b) {
1352  %r = shl <3 x i15> %a, %b
1353  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1354  ret void
1355}
1356
1357; GCN-LABEL: @shl_nsw_3xi15(
1358; SI: %r = shl nsw <3 x i15> %a, %b
1359; SI-NEXT: store volatile <3 x i15> %r
1360; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1361; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1362; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1363; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1364; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1365define amdgpu_kernel void @shl_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1366  %r = shl nsw <3 x i15> %a, %b
1367  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1368  ret void
1369}
1370
1371; GCN-LABEL: @shl_nuw_3xi15(
1372; SI: %r = shl nuw <3 x i15> %a, %b
1373; SI-NEXT: store volatile <3 x i15> %r
1374; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1375; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1376; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1377; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1378; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1379define amdgpu_kernel void @shl_nuw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1380  %r = shl nuw <3 x i15> %a, %b
1381  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1382  ret void
1383}
1384
1385; GCN-LABEL: @shl_nuw_nsw_3xi15(
1386; SI: %r = shl nuw nsw <3 x i15> %a, %b
1387; SI-NEXT: store volatile <3 x i15> %r
1388; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1389; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1390; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1391; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1392; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1393define amdgpu_kernel void @shl_nuw_nsw_3xi15(<3 x i15> %a, <3 x i15> %b) {
1394  %r = shl nuw nsw <3 x i15> %a, %b
1395  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1396  ret void
1397}
1398
1399; GCN-LABEL: @lshr_3xi15(
1400; SI: %r = lshr <3 x i15> %a, %b
1401; SI-NEXT: store volatile <3 x i15> %r
1402; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1403; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1404; VI-NEXT: %[[R_32:[0-9]+]] = lshr <3 x i32> %[[A_32]], %[[B_32]]
1405; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1406; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1407define amdgpu_kernel void @lshr_3xi15(<3 x i15> %a, <3 x i15> %b) {
1408  %r = lshr <3 x i15> %a, %b
1409  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1410  ret void
1411}
1412
1413; GCN-LABEL: @lshr_exact_3xi15(
1414; SI: %r = lshr exact <3 x i15> %a, %b
1415; SI-NEXT: store volatile <3 x i15> %r
1416; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1417; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1418; VI-NEXT: %[[R_32:[0-9]+]] = lshr exact <3 x i32> %[[A_32]], %[[B_32]]
1419; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1420; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1421define amdgpu_kernel void @lshr_exact_3xi15(<3 x i15> %a, <3 x i15> %b) {
1422  %r = lshr exact <3 x i15> %a, %b
1423  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1424  ret void
1425}
1426
1427; GCN-LABEL: @ashr_3xi15(
1428; SI: %r = ashr <3 x i15> %a, %b
1429; SI-NEXT: store volatile <3 x i15> %r
1430; VI: %[[A_32:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1431; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1432; VI-NEXT: %[[R_32:[0-9]+]] = ashr <3 x i32> %[[A_32]], %[[B_32]]
1433; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1434; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1435define amdgpu_kernel void @ashr_3xi15(<3 x i15> %a, <3 x i15> %b) {
1436  %r = ashr <3 x i15> %a, %b
1437  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1438  ret void
1439}
1440
1441; GCN-LABEL: @ashr_exact_3xi15(
1442; SI: %r = ashr exact <3 x i15> %a, %b
1443; SI-NEXT: store volatile <3 x i15> %r
1444; VI: %[[A_32:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1445; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1446; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact <3 x i32> %[[A_32]], %[[B_32]]
1447; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1448; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1449define amdgpu_kernel void @ashr_exact_3xi15(<3 x i15> %a, <3 x i15> %b) {
1450  %r = ashr exact <3 x i15> %a, %b
1451  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1452  ret void
1453}
1454
1455; GCN-LABEL: @and_3xi15(
1456; SI: %r = and <3 x i15> %a, %b
1457; SI-NEXT: store volatile <3 x i15> %r
1458; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1459; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1460; VI-NEXT: %[[R_32:[0-9]+]] = and <3 x i32> %[[A_32]], %[[B_32]]
1461; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1462; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1463define amdgpu_kernel void @and_3xi15(<3 x i15> %a, <3 x i15> %b) {
1464  %r = and <3 x i15> %a, %b
1465  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1466  ret void
1467}
1468
1469; GCN-LABEL: @or_3xi15(
1470; SI: %r = or <3 x i15> %a, %b
1471; SI-NEXT: store volatile <3 x i15> %r
1472; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1473; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1474; VI-NEXT: %[[R_32:[0-9]+]] = or <3 x i32> %[[A_32]], %[[B_32]]
1475; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1476; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1477define amdgpu_kernel void @or_3xi15(<3 x i15> %a, <3 x i15> %b) {
1478  %r = or <3 x i15> %a, %b
1479  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1480  ret void
1481}
1482
1483; GCN-LABEL: @xor_3xi15(
1484; SI: %r = xor <3 x i15> %a, %b
1485; SI-NEXT: store volatile <3 x i15> %r
1486; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1487; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1488; VI-NEXT: %[[R_32:[0-9]+]] = xor <3 x i32> %[[A_32]], %[[B_32]]
1489; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i15>
1490; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1491define amdgpu_kernel void @xor_3xi15(<3 x i15> %a, <3 x i15> %b) {
1492  %r = xor <3 x i15> %a, %b
1493  store volatile <3 x i15> %r, <3 x i15> addrspace(1)* undef
1494  ret void
1495}
1496
1497; GCN-LABEL: @select_eq_3xi15(
1498; SI: %cmp = icmp eq <3 x i15> %a, %b
1499; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1500; SI-NEXT: store volatile <3 x i15> %sel
1501; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1502; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1503; VI-NEXT: %[[CMP:[0-9]+]] = icmp eq <3 x i32> %[[A_32_0]], %[[B_32_0]]
1504; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1505; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1506; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1507; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1508; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1509define amdgpu_kernel void @select_eq_3xi15(<3 x i15> %a, <3 x i15> %b) {
1510  %cmp = icmp eq <3 x i15> %a, %b
1511  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1512  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1513  ret void
1514}
1515
1516; GCN-LABEL: @select_ne_3xi15(
1517; SI: %cmp = icmp ne <3 x i15> %a, %b
1518; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1519; SI-NEXT: store volatile <3 x i15> %sel
1520; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1521; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1522; VI-NEXT: %[[CMP:[0-9]+]] = icmp ne <3 x i32> %[[A_32_0]], %[[B_32_0]]
1523; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1524; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1525; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1526; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1527; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1528define amdgpu_kernel void @select_ne_3xi15(<3 x i15> %a, <3 x i15> %b) {
1529  %cmp = icmp ne <3 x i15> %a, %b
1530  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1531  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1532  ret void
1533}
1534
1535; GCN-LABEL: @select_ugt_3xi15(
1536; SI: %cmp = icmp ugt <3 x i15> %a, %b
1537; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1538; SI-NEXT: store volatile <3 x i15> %sel
1539; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1540; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1541; VI-NEXT: %[[CMP:[0-9]+]] = icmp ugt <3 x i32> %[[A_32_0]], %[[B_32_0]]
1542; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1543; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1544; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1545; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1546; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1547define amdgpu_kernel void @select_ugt_3xi15(<3 x i15> %a, <3 x i15> %b) {
1548  %cmp = icmp ugt <3 x i15> %a, %b
1549  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1550  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1551  ret void
1552}
1553
1554; GCN-LABEL: @select_uge_3xi15(
1555; SI: %cmp = icmp uge <3 x i15> %a, %b
1556; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1557; SI-NEXT: store volatile <3 x i15> %sel
1558; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1559; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1560; VI-NEXT: %[[CMP:[0-9]+]] = icmp uge <3 x i32> %[[A_32_0]], %[[B_32_0]]
1561; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1562; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1563; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1564; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1565; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1566define amdgpu_kernel void @select_uge_3xi15(<3 x i15> %a, <3 x i15> %b) {
1567  %cmp = icmp uge <3 x i15> %a, %b
1568  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1569  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1570  ret void
1571}
1572
1573; GCN-LABEL: @select_ult_3xi15(
1574; SI: %cmp = icmp ult <3 x i15> %a, %b
1575; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1576; SI-NEXT: store volatile <3 x i15> %sel
1577; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1578; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1579; VI-NEXT: %[[CMP:[0-9]+]] = icmp ult <3 x i32> %[[A_32_0]], %[[B_32_0]]
1580; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1581; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1582; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1583; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1584; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1585define amdgpu_kernel void @select_ult_3xi15(<3 x i15> %a, <3 x i15> %b) {
1586  %cmp = icmp ult <3 x i15> %a, %b
1587  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1588  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1589  ret void
1590}
1591
1592; GCN-LABEL: @select_ule_3xi15(
1593; SI: %cmp = icmp ule <3 x i15> %a, %b
1594; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1595; SI-NEXT: store volatile <3 x i15> %sel
1596; VI: %[[A_32_0:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1597; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1598; VI-NEXT: %[[CMP:[0-9]+]] = icmp ule <3 x i32> %[[A_32_0]], %[[B_32_0]]
1599; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1600; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i15> %b to <3 x i32>
1601; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1602; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1603; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1604define amdgpu_kernel void @select_ule_3xi15(<3 x i15> %a, <3 x i15> %b) {
1605  %cmp = icmp ule <3 x i15> %a, %b
1606  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1607  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1608  ret void
1609}
1610
1611; GCN-LABEL: @select_sgt_3xi15(
1612; SI: %cmp = icmp sgt <3 x i15> %a, %b
1613; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1614; SI-NEXT: store volatile <3 x i15> %sel
1615; VI: %[[A_32_0:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1616; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1617; VI-NEXT: %[[CMP:[0-9]+]] = icmp sgt <3 x i32> %[[A_32_0]], %[[B_32_0]]
1618; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1619; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1620; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1621; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1622; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1623define amdgpu_kernel void @select_sgt_3xi15(<3 x i15> %a, <3 x i15> %b) {
1624  %cmp = icmp sgt <3 x i15> %a, %b
1625  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1626  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1627  ret void
1628}
1629
1630; GCN-LABEL: @select_sge_3xi15(
1631; SI: %cmp = icmp sge <3 x i15> %a, %b
1632; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1633; SI-NEXT: store volatile <3 x i15> %sel
1634; VI: %[[A_32_0:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1635; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1636; VI-NEXT: %[[CMP:[0-9]+]] = icmp sge <3 x i32> %[[A_32_0]], %[[B_32_0]]
1637; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1638; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1639; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1640; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1641; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1642define amdgpu_kernel void @select_sge_3xi15(<3 x i15> %a, <3 x i15> %b) {
1643  %cmp = icmp sge <3 x i15> %a, %b
1644  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1645  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1646  ret void
1647}
1648
1649; GCN-LABEL: @select_slt_3xi15(
1650; SI: %cmp = icmp slt <3 x i15> %a, %b
1651; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1652; SI-NEXT: store volatile <3 x i15> %sel
1653; VI: %[[A_32_0:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1654; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1655; VI-NEXT: %[[CMP:[0-9]+]] = icmp slt <3 x i32> %[[A_32_0]], %[[B_32_0]]
1656; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1657; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1658; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1659; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1660; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1661define amdgpu_kernel void @select_slt_3xi15(<3 x i15> %a, <3 x i15> %b) {
1662  %cmp = icmp slt <3 x i15> %a, %b
1663  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1664  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1665  ret void
1666}
1667
1668; GCN-LABEL: @select_sle_3xi15(
1669; SI: %cmp = icmp sle <3 x i15> %a, %b
1670; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1671; SI-NEXT: store volatile <3 x i15> %sel
1672; VI: %[[A_32_0:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1673; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1674; VI-NEXT: %[[CMP:[0-9]+]] = icmp sle <3 x i32> %[[A_32_0]], %[[B_32_0]]
1675; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i15> %a to <3 x i32>
1676; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i15> %b to <3 x i32>
1677; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
1678; VI-NEXT: %[[SEL_15:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i15>
1679; VI-NEXT: store volatile <3 x i15> %[[SEL_15]]
1680define amdgpu_kernel void @select_sle_3xi15(<3 x i15> %a, <3 x i15> %b) {
1681  %cmp = icmp sle <3 x i15> %a, %b
1682  %sel = select <3 x i1> %cmp, <3 x i15> %a, <3 x i15> %b
1683  store volatile <3 x i15> %sel, <3 x i15> addrspace(1)* undef
1684  ret void
1685}
1686
1687declare <3 x i15> @llvm.bitreverse.v3i15(<3 x i15>)
1688; GCN-LABEL: @bitreverse_3xi15(
1689; SI: %brev = call <3 x i15> @llvm.bitreverse.v3i15(<3 x i15> %a)
1690; SI-NEXT: store volatile <3 x i15> %brev
1691; VI: %[[A_32:[0-9]+]] = zext <3 x i15> %a to <3 x i32>
1692; VI-NEXT: %[[R_32:[0-9]+]] = call <3 x i32> @llvm.bitreverse.v3i32(<3 x i32> %[[A_32]])
1693; VI-NEXT: %[[S_32:[0-9]+]] = lshr <3 x i32> %[[R_32]], <i32 17, i32 17, i32 17>
1694; VI-NEXT: %[[R_15:[0-9]+]] = trunc <3 x i32> %[[S_32]] to <3 x i15>
1695; VI-NEXT: store volatile <3 x i15> %[[R_15]]
1696define amdgpu_kernel void @bitreverse_3xi15(<3 x i15> %a) {
1697  %brev = call <3 x i15> @llvm.bitreverse.v3i15(<3 x i15> %a)
1698  store volatile <3 x i15> %brev, <3 x i15> addrspace(1)* undef
1699  ret void
1700}
1701
1702; GCN-LABEL: @add_3xi16(
1703; SI: %r = add <3 x i16> %a, %b
1704; SI-NEXT: store volatile <3 x i16> %r
1705; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1706; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1707; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1708; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1709; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1710define amdgpu_kernel void @add_3xi16(<3 x i16> %a, <3 x i16> %b) {
1711  %r = add <3 x i16> %a, %b
1712  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1713  ret void
1714}
1715
1716; GCN-LABEL: @add_nsw_3xi16(
1717; SI: %r = add nsw <3 x i16> %a, %b
1718; SI-NEXT: store volatile <3 x i16> %r
1719; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1720; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1721; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1722; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1723; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1724define amdgpu_kernel void @add_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1725  %r = add nsw <3 x i16> %a, %b
1726  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1727  ret void
1728}
1729
1730; GCN-LABEL: @add_nuw_3xi16(
1731; SI: %r = add nuw <3 x i16> %a, %b
1732; SI-NEXT: store volatile <3 x i16> %r
1733; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1734; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1735; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1736; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1737; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1738define amdgpu_kernel void @add_nuw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1739  %r = add nuw <3 x i16> %a, %b
1740  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1741  ret void
1742}
1743
1744; GCN-LABEL: @add_nuw_nsw_3xi16(
1745; SI: %r = add nuw nsw <3 x i16> %a, %b
1746; SI-NEXT: store volatile <3 x i16> %r
1747; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1748; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1749; VI-NEXT: %[[R_32:[0-9]+]] = add nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1750; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1751; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1752define amdgpu_kernel void @add_nuw_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1753  %r = add nuw nsw <3 x i16> %a, %b
1754  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1755  ret void
1756}
1757
1758; GCN-LABEL: @sub_3xi16(
1759; SI: %r = sub <3 x i16> %a, %b
1760; SI-NEXT: store volatile <3 x i16> %r
1761; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1762; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1763; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw <3 x i32> %[[A_32]], %[[B_32]]
1764; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1765; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1766define amdgpu_kernel void @sub_3xi16(<3 x i16> %a, <3 x i16> %b) {
1767  %r = sub <3 x i16> %a, %b
1768  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1769  ret void
1770}
1771
1772; GCN-LABEL: @sub_nsw_3xi16(
1773; SI: %r = sub nsw <3 x i16> %a, %b
1774; SI-NEXT: store volatile <3 x i16> %r
1775; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1776; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1777; VI-NEXT: %[[R_32:[0-9]+]] = sub nsw <3 x i32> %[[A_32]], %[[B_32]]
1778; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1779; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1780define amdgpu_kernel void @sub_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1781  %r = sub nsw <3 x i16> %a, %b
1782  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1783  ret void
1784}
1785
1786; GCN-LABEL: @sub_nuw_3xi16(
1787; SI: %r = sub nuw <3 x i16> %a, %b
1788; SI-NEXT: store volatile <3 x i16> %r
1789; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1790; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1791; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1792; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1793; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1794define amdgpu_kernel void @sub_nuw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1795  %r = sub nuw <3 x i16> %a, %b
1796  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1797  ret void
1798}
1799
1800; GCN-LABEL: @sub_nuw_nsw_3xi16(
1801; SI: %r = sub nuw nsw <3 x i16> %a, %b
1802; SI-NEXT: store volatile <3 x i16> %r
1803; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1804; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1805; VI-NEXT: %[[R_32:[0-9]+]] = sub nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1806; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1807; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1808define amdgpu_kernel void @sub_nuw_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1809  %r = sub nuw nsw <3 x i16> %a, %b
1810  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1811  ret void
1812}
1813
1814; GCN-LABEL: @mul_3xi16(
1815; SI: %r = mul <3 x i16> %a, %b
1816; SI-NEXT: store volatile <3 x i16> %r
1817; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1818; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1819; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw <3 x i32> %[[A_32]], %[[B_32]]
1820; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1821; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1822define amdgpu_kernel void @mul_3xi16(<3 x i16> %a, <3 x i16> %b) {
1823  %r = mul <3 x i16> %a, %b
1824  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1825  ret void
1826}
1827
1828; GCN-LABEL: @mul_nsw_3xi16(
1829; SI: %r = mul nsw <3 x i16> %a, %b
1830; SI-NEXT: store volatile <3 x i16> %r
1831; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1832; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1833; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw <3 x i32> %[[A_32]], %[[B_32]]
1834; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1835; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1836define amdgpu_kernel void @mul_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1837  %r = mul nsw <3 x i16> %a, %b
1838  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1839  ret void
1840}
1841
1842; GCN-LABEL: @mul_nuw_3xi16(
1843; SI: %r = mul nuw <3 x i16> %a, %b
1844; SI-NEXT: store volatile <3 x i16> %r
1845; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1846; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1847; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1848; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1849; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1850define amdgpu_kernel void @mul_nuw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1851  %r = mul nuw <3 x i16> %a, %b
1852  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1853  ret void
1854}
1855
1856; GCN-LABEL: @mul_nuw_nsw_3xi16(
1857; SI: %r = mul nuw nsw <3 x i16> %a, %b
1858; SI-NEXT: store volatile <3 x i16> %r
1859; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1860; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1861; VI-NEXT: %[[R_32:[0-9]+]] = mul nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1862; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1863; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1864define amdgpu_kernel void @mul_nuw_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1865  %r = mul nuw nsw <3 x i16> %a, %b
1866  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1867  ret void
1868}
1869
1870; GCN-LABEL: @urem_3xi16(
1871; SI: %r = urem <3 x i16> %a, %b
1872; SI-NEXT: store volatile <3 x i16> %r
1873; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1874; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1875; VI-NEXT: %[[R_32:[0-9]+]] = urem <3 x i32> %[[A_32]], %[[B_32]]
1876; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1877; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1878define amdgpu_kernel void @urem_3xi16(<3 x i16> %a, <3 x i16> %b) {
1879  %r = urem <3 x i16> %a, %b
1880  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1881  ret void
1882}
1883
1884; GCN-LABEL: @srem_3xi16(
1885; SI: %r = srem <3 x i16> %a, %b
1886; SI-NEXT: store volatile <3 x i16> %r
1887; VI: %[[A_32:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
1888; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
1889; VI-NEXT: %[[R_32:[0-9]+]] = srem <3 x i32> %[[A_32]], %[[B_32]]
1890; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1891; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1892define amdgpu_kernel void @srem_3xi16(<3 x i16> %a, <3 x i16> %b) {
1893  %r = srem <3 x i16> %a, %b
1894  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1895  ret void
1896}
1897
1898; GCN-LABEL: @shl_3xi16(
1899; SI: %r = shl <3 x i16> %a, %b
1900; SI-NEXT: store volatile <3 x i16> %r
1901; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1902; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1903; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1904; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1905; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1906define amdgpu_kernel void @shl_3xi16(<3 x i16> %a, <3 x i16> %b) {
1907  %r = shl <3 x i16> %a, %b
1908  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1909  ret void
1910}
1911
1912; GCN-LABEL: @shl_nsw_3xi16(
1913; SI: %r = shl nsw <3 x i16> %a, %b
1914; SI-NEXT: store volatile <3 x i16> %r
1915; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1916; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1917; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1918; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1919; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1920define amdgpu_kernel void @shl_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1921  %r = shl nsw <3 x i16> %a, %b
1922  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1923  ret void
1924}
1925
1926; GCN-LABEL: @shl_nuw_3xi16(
1927; SI: %r = shl nuw <3 x i16> %a, %b
1928; SI-NEXT: store volatile <3 x i16> %r
1929; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1930; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1931; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1932; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1933; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1934define amdgpu_kernel void @shl_nuw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1935  %r = shl nuw <3 x i16> %a, %b
1936  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1937  ret void
1938}
1939
1940; GCN-LABEL: @shl_nuw_nsw_3xi16(
1941; SI: %r = shl nuw nsw <3 x i16> %a, %b
1942; SI-NEXT: store volatile <3 x i16> %r
1943; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1944; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1945; VI-NEXT: %[[R_32:[0-9]+]] = shl nuw nsw <3 x i32> %[[A_32]], %[[B_32]]
1946; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1947; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1948define amdgpu_kernel void @shl_nuw_nsw_3xi16(<3 x i16> %a, <3 x i16> %b) {
1949  %r = shl nuw nsw <3 x i16> %a, %b
1950  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1951  ret void
1952}
1953
1954; GCN-LABEL: @lshr_3xi16(
1955; SI: %r = lshr <3 x i16> %a, %b
1956; SI-NEXT: store volatile <3 x i16> %r
1957; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1958; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1959; VI-NEXT: %[[R_32:[0-9]+]] = lshr <3 x i32> %[[A_32]], %[[B_32]]
1960; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1961; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1962define amdgpu_kernel void @lshr_3xi16(<3 x i16> %a, <3 x i16> %b) {
1963  %r = lshr <3 x i16> %a, %b
1964  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1965  ret void
1966}
1967
1968; GCN-LABEL: @lshr_exact_3xi16(
1969; SI: %r = lshr exact <3 x i16> %a, %b
1970; SI-NEXT: store volatile <3 x i16> %r
1971; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
1972; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
1973; VI-NEXT: %[[R_32:[0-9]+]] = lshr exact <3 x i32> %[[A_32]], %[[B_32]]
1974; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1975; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1976define amdgpu_kernel void @lshr_exact_3xi16(<3 x i16> %a, <3 x i16> %b) {
1977  %r = lshr exact <3 x i16> %a, %b
1978  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1979  ret void
1980}
1981
1982; GCN-LABEL: @ashr_3xi16(
1983; SI: %r = ashr <3 x i16> %a, %b
1984; SI-NEXT: store volatile <3 x i16> %r
1985; VI: %[[A_32:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
1986; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
1987; VI-NEXT: %[[R_32:[0-9]+]] = ashr <3 x i32> %[[A_32]], %[[B_32]]
1988; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
1989; VI-NEXT: store volatile <3 x i16> %[[R_16]]
1990define amdgpu_kernel void @ashr_3xi16(<3 x i16> %a, <3 x i16> %b) {
1991  %r = ashr <3 x i16> %a, %b
1992  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
1993  ret void
1994}
1995
1996; GCN-LABEL: @ashr_exact_3xi16(
1997; SI: %r = ashr exact <3 x i16> %a, %b
1998; SI-NEXT: store volatile <3 x i16> %r
1999; VI: %[[A_32:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2000; VI-NEXT: %[[B_32:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2001; VI-NEXT: %[[R_32:[0-9]+]] = ashr exact <3 x i32> %[[A_32]], %[[B_32]]
2002; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
2003; VI-NEXT: store volatile <3 x i16> %[[R_16]]
2004define amdgpu_kernel void @ashr_exact_3xi16(<3 x i16> %a, <3 x i16> %b) {
2005  %r = ashr exact <3 x i16> %a, %b
2006  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
2007  ret void
2008}
2009
2010; GCN-LABEL: @and_3xi16(
2011; SI: %r = and <3 x i16> %a, %b
2012; SI-NEXT: store volatile <3 x i16> %r
2013; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2014; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2015; VI-NEXT: %[[R_32:[0-9]+]] = and <3 x i32> %[[A_32]], %[[B_32]]
2016; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
2017; VI-NEXT: store volatile <3 x i16> %[[R_16]]
2018define amdgpu_kernel void @and_3xi16(<3 x i16> %a, <3 x i16> %b) {
2019  %r = and <3 x i16> %a, %b
2020  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
2021  ret void
2022}
2023
2024; GCN-LABEL: @or_3xi16(
2025; SI: %r = or <3 x i16> %a, %b
2026; SI-NEXT: store volatile <3 x i16> %r
2027; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2028; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2029; VI-NEXT: %[[R_32:[0-9]+]] = or <3 x i32> %[[A_32]], %[[B_32]]
2030; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
2031; VI-NEXT: store volatile <3 x i16> %[[R_16]]
2032define amdgpu_kernel void @or_3xi16(<3 x i16> %a, <3 x i16> %b) {
2033  %r = or <3 x i16> %a, %b
2034  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
2035  ret void
2036}
2037
2038; GCN-LABEL: @xor_3xi16(
2039; SI: %r = xor <3 x i16> %a, %b
2040; SI-NEXT: store volatile <3 x i16> %r
2041; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2042; VI-NEXT: %[[B_32:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2043; VI-NEXT: %[[R_32:[0-9]+]] = xor <3 x i32> %[[A_32]], %[[B_32]]
2044; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[R_32]] to <3 x i16>
2045; VI-NEXT: store volatile <3 x i16> %[[R_16]]
2046define amdgpu_kernel void @xor_3xi16(<3 x i16> %a, <3 x i16> %b) {
2047  %r = xor <3 x i16> %a, %b
2048  store volatile <3 x i16> %r, <3 x i16> addrspace(1)* undef
2049  ret void
2050}
2051
2052; GCN-LABEL: @select_eq_3xi16(
2053; SI: %cmp = icmp eq <3 x i16> %a, %b
2054; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2055; SI-NEXT: store volatile <3 x i16> %sel
2056; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2057; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2058; VI-NEXT: %[[CMP:[0-9]+]] = icmp eq <3 x i32> %[[A_32_0]], %[[B_32_0]]
2059; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2060; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2061; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2062; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2063; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2064define amdgpu_kernel void @select_eq_3xi16(<3 x i16> %a, <3 x i16> %b) {
2065  %cmp = icmp eq <3 x i16> %a, %b
2066  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2067  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2068  ret void
2069}
2070
2071; GCN-LABEL: @select_ne_3xi16(
2072; SI: %cmp = icmp ne <3 x i16> %a, %b
2073; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2074; SI-NEXT: store volatile <3 x i16> %sel
2075; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2076; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2077; VI-NEXT: %[[CMP:[0-9]+]] = icmp ne <3 x i32> %[[A_32_0]], %[[B_32_0]]
2078; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2079; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2080; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2081; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2082; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2083define amdgpu_kernel void @select_ne_3xi16(<3 x i16> %a, <3 x i16> %b) {
2084  %cmp = icmp ne <3 x i16> %a, %b
2085  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2086  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2087  ret void
2088}
2089
2090; GCN-LABEL: @select_ugt_3xi16(
2091; SI: %cmp = icmp ugt <3 x i16> %a, %b
2092; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2093; SI-NEXT: store volatile <3 x i16> %sel
2094; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2095; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2096; VI-NEXT: %[[CMP:[0-9]+]] = icmp ugt <3 x i32> %[[A_32_0]], %[[B_32_0]]
2097; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2098; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2099; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2100; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2101; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2102define amdgpu_kernel void @select_ugt_3xi16(<3 x i16> %a, <3 x i16> %b) {
2103  %cmp = icmp ugt <3 x i16> %a, %b
2104  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2105  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2106  ret void
2107}
2108
2109; GCN-LABEL: @select_uge_3xi16(
2110; SI: %cmp = icmp uge <3 x i16> %a, %b
2111; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2112; SI-NEXT: store volatile <3 x i16> %sel
2113; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2114; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2115; VI-NEXT: %[[CMP:[0-9]+]] = icmp uge <3 x i32> %[[A_32_0]], %[[B_32_0]]
2116; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2117; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2118; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2119; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2120; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2121define amdgpu_kernel void @select_uge_3xi16(<3 x i16> %a, <3 x i16> %b) {
2122  %cmp = icmp uge <3 x i16> %a, %b
2123  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2124  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2125  ret void
2126}
2127
2128; GCN-LABEL: @select_ult_3xi16(
2129; SI: %cmp = icmp ult <3 x i16> %a, %b
2130; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2131; SI-NEXT: store volatile <3 x i16> %sel
2132; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2133; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2134; VI-NEXT: %[[CMP:[0-9]+]] = icmp ult <3 x i32> %[[A_32_0]], %[[B_32_0]]
2135; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2136; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2137; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2138; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2139; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2140define amdgpu_kernel void @select_ult_3xi16(<3 x i16> %a, <3 x i16> %b) {
2141  %cmp = icmp ult <3 x i16> %a, %b
2142  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2143  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2144  ret void
2145}
2146
2147; GCN-LABEL: @select_ule_3xi16(
2148; SI: %cmp = icmp ule <3 x i16> %a, %b
2149; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2150; SI-NEXT: store volatile <3 x i16> %sel
2151; VI: %[[A_32_0:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2152; VI-NEXT: %[[B_32_0:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2153; VI-NEXT: %[[CMP:[0-9]+]] = icmp ule <3 x i32> %[[A_32_0]], %[[B_32_0]]
2154; VI-NEXT: %[[A_32_1:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2155; VI-NEXT: %[[B_32_1:[0-9]+]] = zext <3 x i16> %b to <3 x i32>
2156; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2157; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2158; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2159define amdgpu_kernel void @select_ule_3xi16(<3 x i16> %a, <3 x i16> %b) {
2160  %cmp = icmp ule <3 x i16> %a, %b
2161  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2162  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2163  ret void
2164}
2165
2166; GCN-LABEL: @select_sgt_3xi16(
2167; SI: %cmp = icmp sgt <3 x i16> %a, %b
2168; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2169; SI-NEXT: store volatile <3 x i16> %sel
2170; VI: %[[A_32_0:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2171; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2172; VI-NEXT: %[[CMP:[0-9]+]] = icmp sgt <3 x i32> %[[A_32_0]], %[[B_32_0]]
2173; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2174; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2175; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2176; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2177; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2178define amdgpu_kernel void @select_sgt_3xi16(<3 x i16> %a, <3 x i16> %b) {
2179  %cmp = icmp sgt <3 x i16> %a, %b
2180  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2181  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2182  ret void
2183}
2184
2185; GCN-LABEL: @select_sge_3xi16(
2186; SI: %cmp = icmp sge <3 x i16> %a, %b
2187; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2188; SI-NEXT: store volatile <3 x i16> %sel
2189; VI: %[[A_32_0:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2190; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2191; VI-NEXT: %[[CMP:[0-9]+]] = icmp sge <3 x i32> %[[A_32_0]], %[[B_32_0]]
2192; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2193; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2194; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2195; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2196; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2197define amdgpu_kernel void @select_sge_3xi16(<3 x i16> %a, <3 x i16> %b) {
2198  %cmp = icmp sge <3 x i16> %a, %b
2199  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2200  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2201  ret void
2202}
2203
2204; GCN-LABEL: @select_slt_3xi16(
2205; SI: %cmp = icmp slt <3 x i16> %a, %b
2206; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2207; SI-NEXT: store volatile <3 x i16> %sel
2208; VI: %[[A_32_0:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2209; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2210; VI-NEXT: %[[CMP:[0-9]+]] = icmp slt <3 x i32> %[[A_32_0]], %[[B_32_0]]
2211; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2212; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2213; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2214; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2215; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2216define amdgpu_kernel void @select_slt_3xi16(<3 x i16> %a, <3 x i16> %b) {
2217  %cmp = icmp slt <3 x i16> %a, %b
2218  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2219  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2220  ret void
2221}
2222
2223; GCN-LABEL: @select_sle_3xi16(
2224; SI: %cmp = icmp sle <3 x i16> %a, %b
2225; SI-NEXT: %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2226; SI-NEXT: store volatile <3 x i16> %sel
2227; VI: %[[A_32_0:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2228; VI-NEXT: %[[B_32_0:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2229; VI-NEXT: %[[CMP:[0-9]+]] = icmp sle <3 x i32> %[[A_32_0]], %[[B_32_0]]
2230; VI-NEXT: %[[A_32_1:[0-9]+]] = sext <3 x i16> %a to <3 x i32>
2231; VI-NEXT: %[[B_32_1:[0-9]+]] = sext <3 x i16> %b to <3 x i32>
2232; VI-NEXT: %[[SEL_32:[0-9]+]] = select <3 x i1> %[[CMP]], <3 x i32> %[[A_32_1]], <3 x i32> %[[B_32_1]]
2233; VI-NEXT: %[[SEL_16:[0-9]+]] = trunc <3 x i32> %[[SEL_32]] to <3 x i16>
2234; VI-NEXT: store volatile <3 x i16> %[[SEL_16]]
2235define amdgpu_kernel void @select_sle_3xi16(<3 x i16> %a, <3 x i16> %b) {
2236  %cmp = icmp sle <3 x i16> %a, %b
2237  %sel = select <3 x i1> %cmp, <3 x i16> %a, <3 x i16> %b
2238  store volatile <3 x i16> %sel, <3 x i16> addrspace(1)* undef
2239  ret void
2240}
2241
2242declare <3 x i16> @llvm.bitreverse.v3i16(<3 x i16>)
2243
2244; GCN-LABEL: @bitreverse_3xi16(
2245; SI: %brev = call <3 x i16> @llvm.bitreverse.v3i16(<3 x i16> %a)
2246; SI-NEXT: store volatile <3 x i16> %brev
2247; VI: %[[A_32:[0-9]+]] = zext <3 x i16> %a to <3 x i32>
2248; VI-NEXT: %[[R_32:[0-9]+]] = call <3 x i32> @llvm.bitreverse.v3i32(<3 x i32> %[[A_32]])
2249; VI-NEXT: %[[S_32:[0-9]+]] = lshr <3 x i32> %[[R_32]], <i32 16, i32 16, i32 16>
2250; VI-NEXT: %[[R_16:[0-9]+]] = trunc <3 x i32> %[[S_32]] to <3 x i16>
2251; VI-NEXT: store volatile <3 x i16> %[[R_16]]
2252define amdgpu_kernel void @bitreverse_3xi16(<3 x i16> %a) {
2253  %brev = call <3 x i16> @llvm.bitreverse.v3i16(<3 x i16> %a)
2254  store volatile <3 x i16> %brev, <3 x i16> addrspace(1)* undef
2255  ret void
2256}
2257