1 ; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc < %s -march=r600 -mcpu=cypress | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4 ; FUNC-LABEL: @sext_in_reg_i1_i32
5 ; SI: S_LOAD_DWORD [[ARG:s[0-9]+]],
6 ; SI: V_BFE_I32 [[EXTRACT:v[0-9]+]], [[ARG]], 0, 1
7 ; SI: BUFFER_STORE_DWORD [[EXTRACT]],
10 define void @sext_in_reg_i1_i32(i32 addrspace(1)* %out, i32 %in) {
11 %shl = shl i32 %in, 31
12 %sext = ashr i32 %shl, 31
13 store i32 %sext, i32 addrspace(1)* %out
17 ; FUNC-LABEL: @sext_in_reg_i8_to_i32
18 ; SI: S_ADD_I32 [[VAL:s[0-9]+]],
19 ; SI: V_BFE_I32 [[EXTRACT:v[0-9]+]], [[VAL]], 0, 8
20 ; SI: BUFFER_STORE_DWORD [[EXTRACT]],
23 define void @sext_in_reg_i8_to_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
24 %c = add i32 %a, %b ; add to prevent folding into extload
26 %ashr = ashr i32 %shl, 24
27 store i32 %ashr, i32 addrspace(1)* %out, align 4
31 ; FUNC-LABEL: @sext_in_reg_i16_to_i32
32 ; SI: S_ADD_I32 [[VAL:s[0-9]+]],
33 ; SI: V_BFE_I32 [[EXTRACT:v[0-9]+]], [[VAL]], 0, 16
34 ; SI: BUFFER_STORE_DWORD [[EXTRACT]],
37 define void @sext_in_reg_i16_to_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
38 %c = add i32 %a, %b ; add to prevent folding into extload
40 %ashr = ashr i32 %shl, 16
41 store i32 %ashr, i32 addrspace(1)* %out, align 4
45 ; FUNC-LABEL: @sext_in_reg_i8_to_v1i32
46 ; SI: S_ADD_I32 [[VAL:s[0-9]+]],
47 ; SI: V_BFE_I32 [[EXTRACT:v[0-9]+]], [[VAL]], 0, 8
48 ; SI: BUFFER_STORE_DWORD [[EXTRACT]],
51 define void @sext_in_reg_i8_to_v1i32(<1 x i32> addrspace(1)* %out, <1 x i32> %a, <1 x i32> %b) nounwind {
52 %c = add <1 x i32> %a, %b ; add to prevent folding into extload
53 %shl = shl <1 x i32> %c, <i32 24>
54 %ashr = ashr <1 x i32> %shl, <i32 24>
55 store <1 x i32> %ashr, <1 x i32> addrspace(1)* %out, align 4
59 ; FUNC-LABEL: @sext_in_reg_i8_to_i64
60 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
61 ; SI: V_ASHRREV_I32_e32 {{v[0-9]+}}, 31,
62 ; SI: BUFFER_STORE_DWORD
66 define void @sext_in_reg_i8_to_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
69 %ashr = ashr i64 %shl, 56
70 store i64 %ashr, i64 addrspace(1)* %out, align 8
74 ; FUNC-LABEL: @sext_in_reg_i16_to_i64
75 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 16
76 ; SI: V_ASHRREV_I32_e32 {{v[0-9]+}}, 31,
77 ; SI: BUFFER_STORE_DWORD
81 define void @sext_in_reg_i16_to_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
84 %ashr = ashr i64 %shl, 48
85 store i64 %ashr, i64 addrspace(1)* %out, align 8
89 ; This is broken on Evergreen for some reason related to the <1 x i64> kernel arguments.
90 ; XFUNC-LABEL: @sext_in_reg_i8_to_v1i64
91 ; XSI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
92 ; XSI: V_ASHRREV_I32_e32 {{v[0-9]+}}, 31,
93 ; XSI: BUFFER_STORE_DWORD
96 ; define void @sext_in_reg_i8_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i64> %a, <1 x i64> %b) nounwind {
97 ; %c = add <1 x i64> %a, %b
98 ; %shl = shl <1 x i64> %c, <i64 56>
99 ; %ashr = ashr <1 x i64> %shl, <i64 56>
100 ; store <1 x i64> %ashr, <1 x i64> addrspace(1)* %out, align 8
104 ; FUNC-LABEL: @sext_in_reg_i1_in_i32_other_amount
106 ; SI: S_LSHL_B32 [[REG:s[0-9]+]], {{s[0-9]+}}, 6
107 ; SI: S_ASHR_I32 {{s[0-9]+}}, [[REG]], 7
109 define void @sext_in_reg_i1_in_i32_other_amount(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
113 store i32 %y, i32 addrspace(1)* %out
117 ; FUNC-LABEL: @sext_in_reg_v2i1_in_v2i32_other_amount
118 ; SI: S_LSHL_B32 [[REG0:s[0-9]+]], {{s[0-9]}}, 6
119 ; SI: S_ASHR_I32 {{s[0-9]+}}, [[REG0]], 7
120 ; SI: S_LSHL_B32 [[REG1:s[0-9]+]], {{s[0-9]}}, 6
121 ; SI: S_ASHR_I32 {{s[0-9]+}}, [[REG1]], 7
123 define void @sext_in_reg_v2i1_in_v2i32_other_amount(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) nounwind {
124 %c = add <2 x i32> %a, %b
125 %x = shl <2 x i32> %c, <i32 6, i32 6>
126 %y = ashr <2 x i32> %x, <i32 7, i32 7>
127 store <2 x i32> %y, <2 x i32> addrspace(1)* %out, align 2
132 ; FUNC-LABEL: @sext_in_reg_v2i1_to_v2i32
133 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
134 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
135 ; SI: BUFFER_STORE_DWORDX2
138 define void @sext_in_reg_v2i1_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) nounwind {
139 %c = add <2 x i32> %a, %b ; add to prevent folding into extload
140 %shl = shl <2 x i32> %c, <i32 31, i32 31>
141 %ashr = ashr <2 x i32> %shl, <i32 31, i32 31>
142 store <2 x i32> %ashr, <2 x i32> addrspace(1)* %out, align 8
146 ; FUNC-LABEL: @sext_in_reg_v4i1_to_v4i32
147 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
148 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
149 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
150 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 1
151 ; SI: BUFFER_STORE_DWORDX4
157 define void @sext_in_reg_v4i1_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %a, <4 x i32> %b) nounwind {
158 %c = add <4 x i32> %a, %b ; add to prevent folding into extload
159 %shl = shl <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
160 %ashr = ashr <4 x i32> %shl, <i32 31, i32 31, i32 31, i32 31>
161 store <4 x i32> %ashr, <4 x i32> addrspace(1)* %out, align 8
165 ; FUNC-LABEL: @sext_in_reg_v2i8_to_v2i32
166 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
167 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
168 ; SI: BUFFER_STORE_DWORDX2
172 define void @sext_in_reg_v2i8_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) nounwind {
173 %c = add <2 x i32> %a, %b ; add to prevent folding into extload
174 %shl = shl <2 x i32> %c, <i32 24, i32 24>
175 %ashr = ashr <2 x i32> %shl, <i32 24, i32 24>
176 store <2 x i32> %ashr, <2 x i32> addrspace(1)* %out, align 8
180 ; FUNC-LABEL: @sext_in_reg_v4i8_to_v4i32
181 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
182 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
183 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
184 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
185 ; SI: BUFFER_STORE_DWORDX4
191 define void @sext_in_reg_v4i8_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %a, <4 x i32> %b) nounwind {
192 %c = add <4 x i32> %a, %b ; add to prevent folding into extload
193 %shl = shl <4 x i32> %c, <i32 24, i32 24, i32 24, i32 24>
194 %ashr = ashr <4 x i32> %shl, <i32 24, i32 24, i32 24, i32 24>
195 store <4 x i32> %ashr, <4 x i32> addrspace(1)* %out, align 8
199 ; FUNC-LABEL: @sext_in_reg_v2i16_to_v2i32
200 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
201 ; SI: V_BFE_I32 {{v[0-9]+}}, {{s[0-9]+}}, 0, 8
202 ; SI: BUFFER_STORE_DWORDX2
206 define void @sext_in_reg_v2i16_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) nounwind {
207 %c = add <2 x i32> %a, %b ; add to prevent folding into extload
208 %shl = shl <2 x i32> %c, <i32 24, i32 24>
209 %ashr = ashr <2 x i32> %shl, <i32 24, i32 24>
210 store <2 x i32> %ashr, <2 x i32> addrspace(1)* %out, align 8
214 ; FUNC-LABEL: @testcase
215 define void @testcase(i8 addrspace(1)* %out, i8 %a) nounwind {
216 %and_a_1 = and i8 %a, 1
217 %cmp_eq = icmp eq i8 %and_a_1, 0
218 %cmp_slt = icmp slt i8 %a, 0
219 %sel0 = select i1 %cmp_slt, i8 0, i8 %a
220 %sel1 = select i1 %cmp_eq, i8 0, i8 %a
221 %xor = xor i8 %sel0, %sel1
222 store i8 %xor, i8 addrspace(1)* %out
226 ; FUNC-LABEL: @testcase_3
227 define void @testcase_3(i8 addrspace(1)* %out, i8 %a) nounwind {
228 %and_a_1 = and i8 %a, 1
229 %cmp_eq = icmp eq i8 %and_a_1, 0
230 %cmp_slt = icmp slt i8 %a, 0
231 %sel0 = select i1 %cmp_slt, i8 0, i8 %a
232 %sel1 = select i1 %cmp_eq, i8 0, i8 %a
233 %xor = xor i8 %sel0, %sel1
234 store i8 %xor, i8 addrspace(1)* %out