1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck --check-prefix=GCN %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX8 %s
4 ; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9 %s
6 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
7 declare i32 @llvm.amdgcn.workitem.id.y() nounwind readnone
9 define amdgpu_kernel void @anyext_i1_i32(i32 addrspace(1)* %out, i32 %cond) #0 {
10 ; GCN-LABEL: anyext_i1_i32:
11 ; GCN: ; %bb.0: ; %entry
12 ; GCN-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
13 ; GCN-NEXT: s_load_dword s0, s[0:1], 0xb
14 ; GCN-NEXT: s_mov_b32 s7, 0xf000
15 ; GCN-NEXT: s_mov_b32 s6, -1
16 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
17 ; GCN-NEXT: v_cmp_ne_u32_e64 s[0:1], s0, 0
18 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, 1, s[0:1]
19 ; GCN-NEXT: buffer_store_dword v0, off, s[4:7], 0
22 ; GFX8-LABEL: anyext_i1_i32:
23 ; GFX8: ; %bb.0: ; %entry
24 ; GFX8-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
25 ; GFX8-NEXT: s_load_dword s0, s[0:1], 0x2c
26 ; GFX8-NEXT: s_mov_b32 s7, 0xf000
27 ; GFX8-NEXT: s_mov_b32 s6, -1
28 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
29 ; GFX8-NEXT: v_cmp_eq_u32_e64 s[0:1], s0, 0
30 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, s[0:1]
31 ; GFX8-NEXT: v_not_b32_e32 v0, v0
32 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
33 ; GFX8-NEXT: buffer_store_dword v0, off, s[4:7], 0
36 ; GFX9-LABEL: anyext_i1_i32:
37 ; GFX9: ; %bb.0: ; %entry
38 ; GFX9-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
39 ; GFX9-NEXT: s_load_dword s2, s[0:1], 0x2c
40 ; GFX9-NEXT: s_mov_b32 s7, 0xf000
41 ; GFX9-NEXT: s_mov_b32 s6, -1
42 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
43 ; GFX9-NEXT: v_cmp_eq_u32_e64 s[0:1], s2, 0
44 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, s[0:1]
45 ; GFX9-NEXT: v_not_b32_e32 v0, v0
46 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
47 ; GFX9-NEXT: buffer_store_dword v0, off, s[4:7], 0
50 %tmp = icmp eq i32 %cond, 0
51 %tmp1 = zext i1 %tmp to i8
52 %tmp2 = xor i8 %tmp1, -1
53 %tmp3 = and i8 %tmp2, 1
54 %tmp4 = zext i8 %tmp3 to i32
55 store i32 %tmp4, i32 addrspace(1)* %out
59 define amdgpu_kernel void @s_anyext_i16_i32(i32 addrspace(1)* %out, i16 addrspace(1)* %a, i16 addrspace(1)* %b) #0 {
60 ; GCN-LABEL: s_anyext_i16_i32:
61 ; GCN: ; %bb.0: ; %entry
62 ; GCN-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
63 ; GCN-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
64 ; GCN-NEXT: s_mov_b32 s11, 0xf000
65 ; GCN-NEXT: v_lshlrev_b32_e32 v2, 1, v0
66 ; GCN-NEXT: s_mov_b32 s14, 0
67 ; GCN-NEXT: s_mov_b32 s15, s11
68 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
69 ; GCN-NEXT: s_mov_b64 s[12:13], s[6:7]
70 ; GCN-NEXT: v_mov_b32_e32 v3, 0
71 ; GCN-NEXT: v_lshlrev_b32_e32 v0, 1, v1
72 ; GCN-NEXT: s_mov_b64 s[2:3], s[14:15]
73 ; GCN-NEXT: v_mov_b32_e32 v1, v3
74 ; GCN-NEXT: buffer_load_ushort v2, v[2:3], s[12:15], 0 addr64
75 ; GCN-NEXT: buffer_load_ushort v0, v[0:1], s[0:3], 0 addr64
76 ; GCN-NEXT: s_mov_b32 s10, -1
77 ; GCN-NEXT: s_mov_b32 s8, s4
78 ; GCN-NEXT: s_mov_b32 s9, s5
79 ; GCN-NEXT: s_waitcnt vmcnt(0)
80 ; GCN-NEXT: v_add_i32_e32 v0, vcc, v2, v0
81 ; GCN-NEXT: v_not_b32_e32 v0, v0
82 ; GCN-NEXT: v_and_b32_e32 v0, 1, v0
83 ; GCN-NEXT: buffer_store_dword v0, off, s[8:11], 0
86 ; GFX8-LABEL: s_anyext_i16_i32:
87 ; GFX8: ; %bb.0: ; %entry
88 ; GFX8-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
89 ; GFX8-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x34
90 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 1, v0
91 ; GFX8-NEXT: s_mov_b32 s3, 0xf000
92 ; GFX8-NEXT: s_mov_b32 s2, -1
93 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
94 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, s6, v0
95 ; GFX8-NEXT: v_mov_b32_e32 v3, s7
96 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 1, v1
97 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, 0, v3, vcc
98 ; GFX8-NEXT: v_mov_b32_e32 v1, s9
99 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s8, v0
100 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
101 ; GFX8-NEXT: flat_load_ushort v2, v[2:3]
102 ; GFX8-NEXT: flat_load_ushort v0, v[0:1]
103 ; GFX8-NEXT: s_mov_b32 s0, s4
104 ; GFX8-NEXT: s_mov_b32 s1, s5
105 ; GFX8-NEXT: s_waitcnt vmcnt(0)
106 ; GFX8-NEXT: v_add_u16_e32 v0, v2, v0
107 ; GFX8-NEXT: v_xor_b32_e32 v0, -1, v0
108 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
109 ; GFX8-NEXT: v_and_b32_e32 v0, 0xffff, v0
110 ; GFX8-NEXT: buffer_store_dword v0, off, s[0:3], 0
111 ; GFX8-NEXT: s_endpgm
113 ; GFX9-LABEL: s_anyext_i16_i32:
114 ; GFX9: ; %bb.0: ; %entry
115 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
116 ; GFX9-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x34
117 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 1, v0
118 ; GFX9-NEXT: v_lshlrev_b32_e32 v1, 1, v1
119 ; GFX9-NEXT: s_mov_b32 s3, 0xf000
120 ; GFX9-NEXT: s_mov_b32 s2, -1
121 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
122 ; GFX9-NEXT: global_load_ushort v2, v0, s[6:7]
123 ; GFX9-NEXT: global_load_ushort v3, v1, s[8:9]
124 ; GFX9-NEXT: s_mov_b32 s0, s4
125 ; GFX9-NEXT: s_mov_b32 s1, s5
126 ; GFX9-NEXT: s_waitcnt vmcnt(0)
127 ; GFX9-NEXT: v_add_u16_e32 v0, v2, v3
128 ; GFX9-NEXT: v_xor_b32_e32 v0, -1, v0
129 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
130 ; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0
131 ; GFX9-NEXT: buffer_store_dword v0, off, s[0:3], 0
132 ; GFX9-NEXT: s_endpgm
134 %tid.x = call i32 @llvm.amdgcn.workitem.id.x()
135 %tid.y = call i32 @llvm.amdgcn.workitem.id.y()
136 %a.ptr = getelementptr i16, i16 addrspace(1)* %a, i32 %tid.x
137 %b.ptr = getelementptr i16, i16 addrspace(1)* %b, i32 %tid.y
138 %a.l = load i16, i16 addrspace(1)* %a.ptr
139 %b.l = load i16, i16 addrspace(1)* %b.ptr
140 %tmp = add i16 %a.l, %b.l
141 %tmp1 = trunc i16 %tmp to i8
142 %tmp2 = xor i8 %tmp1, -1
143 %tmp3 = and i8 %tmp2, 1
144 %tmp4 = zext i8 %tmp3 to i32
145 store i32 %tmp4, i32 addrspace(1)* %out
149 define amdgpu_kernel void @anyext_v2i16_to_v2i32() #0 {
150 ; GCN-LABEL: anyext_v2i16_to_v2i32:
151 ; GCN: ; %bb.0: ; %bb
152 ; GCN-NEXT: s_mov_b32 s3, 0xf000
153 ; GCN-NEXT: s_mov_b32 s2, -1
154 ; GCN-NEXT: buffer_load_ushort v0, off, s[0:3], 0
155 ; GCN-NEXT: s_waitcnt vmcnt(0)
156 ; GCN-NEXT: v_and_b32_e32 v0, 0x8000, v0
157 ; GCN-NEXT: v_lshlrev_b32_e32 v0, 16, v0
158 ; GCN-NEXT: v_cmp_eq_f32_e32 vcc, 0, v0
159 ; GCN-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
160 ; GCN-NEXT: buffer_store_byte v0, off, s[0:3], 0
163 ; GFX8-LABEL: anyext_v2i16_to_v2i32:
164 ; GFX8: ; %bb.0: ; %bb
165 ; GFX8-NEXT: s_mov_b32 s3, 0xf000
166 ; GFX8-NEXT: s_mov_b32 s2, -1
167 ; GFX8-NEXT: buffer_load_ushort v0, off, s[0:3], 0
168 ; GFX8-NEXT: v_mov_b32_e32 v1, 0x8000
169 ; GFX8-NEXT: s_waitcnt vmcnt(0)
170 ; GFX8-NEXT: v_and_b32_sdwa v0, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
171 ; GFX8-NEXT: v_cmp_eq_f32_e32 vcc, 0, v0
172 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
173 ; GFX8-NEXT: buffer_store_byte v0, off, s[0:3], 0
174 ; GFX8-NEXT: s_endpgm
176 ; GFX9-LABEL: anyext_v2i16_to_v2i32:
177 ; GFX9: ; %bb.0: ; %bb
178 ; GFX9-NEXT: global_load_short_d16_hi v0, v[0:1], off
179 ; GFX9-NEXT: v_mov_b32_e32 v1, 0xffff
180 ; GFX9-NEXT: s_mov_b32 s3, 0xf000
181 ; GFX9-NEXT: s_mov_b32 s2, -1
182 ; GFX9-NEXT: s_waitcnt vmcnt(0)
183 ; GFX9-NEXT: v_and_b32_e32 v0, 0x80008000, v0
184 ; GFX9-NEXT: v_bfi_b32 v0, v1, 0, v0
185 ; GFX9-NEXT: v_cmp_eq_f32_e32 vcc, 0, v0
186 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
187 ; GFX9-NEXT: buffer_store_byte v0, off, s[0:3], 0
188 ; GFX9-NEXT: s_endpgm
190 %tmp = load i16, i16 addrspace(1)* undef, align 2
191 %tmp2 = insertelement <2 x i16> undef, i16 %tmp, i32 1
192 %tmp4 = and <2 x i16> %tmp2, <i16 -32768, i16 -32768>
193 %tmp5 = zext <2 x i16> %tmp4 to <2 x i32>
194 %tmp6 = shl nuw <2 x i32> %tmp5, <i32 16, i32 16>
195 %tmp7 = or <2 x i32> zeroinitializer, %tmp6
196 %tmp8 = bitcast <2 x i32> %tmp7 to <2 x float>
197 %tmp10 = fcmp oeq <2 x float> %tmp8, zeroinitializer
198 %tmp11 = zext <2 x i1> %tmp10 to <2 x i8>
199 %tmp12 = extractelement <2 x i8> %tmp11, i32 1
200 store i8 %tmp12, i8 addrspace(1)* undef, align 1
204 attributes #0 = { nounwind }