1 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
4 declare i32 @llvm.r600.read.tidig.x() nounwind readnone
6 ; FUNC-LABEL: {{^}}setcc_v2i32:
7 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW]}}, KC0[3].X, KC0[3].Z
8 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW]}}, KC0[2].W, KC0[3].Y
10 define void @setcc_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) {
11 %result = icmp eq <2 x i32> %a, %b
12 %sext = sext <2 x i1> %result to <2 x i32>
13 store <2 x i32> %sext, <2 x i32> addrspace(1)* %out
17 ; FUNC-LABEL: {{^}}setcc_v4i32:
18 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
19 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
20 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
21 ; R600-DAG: SETE_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
23 define void @setcc_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
24 %b_ptr = getelementptr <4 x i32> addrspace(1)* %in, i32 1
25 %a = load <4 x i32> addrspace(1) * %in
26 %b = load <4 x i32> addrspace(1) * %b_ptr
27 %result = icmp eq <4 x i32> %a, %b
28 %sext = sext <4 x i1> %result to <4 x i32>
29 store <4 x i32> %sext, <4 x i32> addrspace(1)* %out
33 ;;;==========================================================================;;;
35 ;;;==========================================================================;;;
37 ; FUNC-LABEL: {{^}}f32_oeq:
40 define void @f32_oeq(i32 addrspace(1)* %out, float %a, float %b) {
42 %0 = fcmp oeq float %a, %b
43 %1 = sext i1 %0 to i32
44 store i32 %1, i32 addrspace(1)* %out
48 ; FUNC-LABEL: {{^}}f32_ogt:
51 define void @f32_ogt(i32 addrspace(1)* %out, float %a, float %b) {
53 %0 = fcmp ogt float %a, %b
54 %1 = sext i1 %0 to i32
55 store i32 %1, i32 addrspace(1)* %out
59 ; FUNC-LABEL: {{^}}f32_oge:
62 define void @f32_oge(i32 addrspace(1)* %out, float %a, float %b) {
64 %0 = fcmp oge float %a, %b
65 %1 = sext i1 %0 to i32
66 store i32 %1, i32 addrspace(1)* %out
70 ; FUNC-LABEL: {{^}}f32_olt:
73 define void @f32_olt(i32 addrspace(1)* %out, float %a, float %b) {
75 %0 = fcmp olt float %a, %b
76 %1 = sext i1 %0 to i32
77 store i32 %1, i32 addrspace(1)* %out
81 ; FUNC-LABEL: {{^}}f32_ole:
84 define void @f32_ole(i32 addrspace(1)* %out, float %a, float %b) {
86 %0 = fcmp ole float %a, %b
87 %1 = sext i1 %0 to i32
88 store i32 %1, i32 addrspace(1)* %out
92 ; FUNC-LABEL: {{^}}f32_one:
96 ; R600-DAG: SETNE_DX10
101 ; SI: v_cndmask_b32_e64
102 ; SI: v_cndmask_b32_e64
104 define void @f32_one(i32 addrspace(1)* %out, float %a, float %b) {
106 %0 = fcmp one float %a, %b
107 %1 = sext i1 %0 to i32
108 store i32 %1, i32 addrspace(1)* %out
112 ; FUNC-LABEL: {{^}}f32_ord:
113 ; R600-DAG: SETE_DX10
114 ; R600-DAG: SETE_DX10
116 ; R600-DAG: SETNE_INT
118 define void @f32_ord(i32 addrspace(1)* %out, float %a, float %b) {
120 %0 = fcmp ord float %a, %b
121 %1 = sext i1 %0 to i32
122 store i32 %1, i32 addrspace(1)* %out
126 ; FUNC-LABEL: {{^}}f32_ueq:
127 ; R600-DAG: SETNE_DX10
128 ; R600-DAG: SETNE_DX10
130 ; R600-DAG: SETE_DX10
132 ; R600-DAG: SETNE_INT
135 ; SI: v_cndmask_b32_e64
136 ; SI: v_cndmask_b32_e64
138 define void @f32_ueq(i32 addrspace(1)* %out, float %a, float %b) {
140 %0 = fcmp ueq float %a, %b
141 %1 = sext i1 %0 to i32
142 store i32 %1, i32 addrspace(1)* %out
146 ; FUNC-LABEL: {{^}}f32_ugt:
151 ; SI: v_cndmask_b32_e64
152 ; SI: v_cndmask_b32_e64
154 define void @f32_ugt(i32 addrspace(1)* %out, float %a, float %b) {
156 %0 = fcmp ugt float %a, %b
157 %1 = sext i1 %0 to i32
158 store i32 %1, i32 addrspace(1)* %out
162 ; FUNC-LABEL: {{^}}f32_uge:
167 ; SI: v_cndmask_b32_e64
168 ; SI: v_cndmask_b32_e64
170 define void @f32_uge(i32 addrspace(1)* %out, float %a, float %b) {
172 %0 = fcmp uge float %a, %b
173 %1 = sext i1 %0 to i32
174 store i32 %1, i32 addrspace(1)* %out
178 ; FUNC-LABEL: {{^}}f32_ult:
183 ; SI: v_cndmask_b32_e64
184 ; SI: v_cndmask_b32_e64
186 define void @f32_ult(i32 addrspace(1)* %out, float %a, float %b) {
188 %0 = fcmp ult float %a, %b
189 %1 = sext i1 %0 to i32
190 store i32 %1, i32 addrspace(1)* %out
194 ; FUNC-LABEL: {{^}}f32_ule:
199 ; SI: v_cndmask_b32_e64
200 ; SI: v_cndmask_b32_e64
202 define void @f32_ule(i32 addrspace(1)* %out, float %a, float %b) {
204 %0 = fcmp ule float %a, %b
205 %1 = sext i1 %0 to i32
206 store i32 %1, i32 addrspace(1)* %out
210 ; FUNC-LABEL: {{^}}f32_une:
213 define void @f32_une(i32 addrspace(1)* %out, float %a, float %b) {
215 %0 = fcmp une float %a, %b
216 %1 = sext i1 %0 to i32
217 store i32 %1, i32 addrspace(1)* %out
221 ; FUNC-LABEL: {{^}}f32_uno:
227 define void @f32_uno(i32 addrspace(1)* %out, float %a, float %b) {
229 %0 = fcmp uno float %a, %b
230 %1 = sext i1 %0 to i32
231 store i32 %1, i32 addrspace(1)* %out
235 ;;;==========================================================================;;;
236 ;; 32-bit integer comparisons
237 ;;;==========================================================================;;;
239 ; FUNC-LABEL: {{^}}i32_eq:
242 define void @i32_eq(i32 addrspace(1)* %out, i32 %a, i32 %b) {
244 %0 = icmp eq i32 %a, %b
245 %1 = sext i1 %0 to i32
246 store i32 %1, i32 addrspace(1)* %out
250 ; FUNC-LABEL: {{^}}i32_ne:
253 define void @i32_ne(i32 addrspace(1)* %out, i32 %a, i32 %b) {
255 %0 = icmp ne i32 %a, %b
256 %1 = sext i1 %0 to i32
257 store i32 %1, i32 addrspace(1)* %out
261 ; FUNC-LABEL: {{^}}i32_ugt:
264 define void @i32_ugt(i32 addrspace(1)* %out, i32 %a, i32 %b) {
266 %0 = icmp ugt i32 %a, %b
267 %1 = sext i1 %0 to i32
268 store i32 %1, i32 addrspace(1)* %out
272 ; FUNC-LABEL: {{^}}i32_uge:
275 define void @i32_uge(i32 addrspace(1)* %out, i32 %a, i32 %b) {
277 %0 = icmp uge i32 %a, %b
278 %1 = sext i1 %0 to i32
279 store i32 %1, i32 addrspace(1)* %out
283 ; FUNC-LABEL: {{^}}i32_ult:
286 define void @i32_ult(i32 addrspace(1)* %out, i32 %a, i32 %b) {
288 %0 = icmp ult i32 %a, %b
289 %1 = sext i1 %0 to i32
290 store i32 %1, i32 addrspace(1)* %out
294 ; FUNC-LABEL: {{^}}i32_ule:
297 define void @i32_ule(i32 addrspace(1)* %out, i32 %a, i32 %b) {
299 %0 = icmp ule i32 %a, %b
300 %1 = sext i1 %0 to i32
301 store i32 %1, i32 addrspace(1)* %out
305 ; FUNC-LABEL: {{^}}i32_sgt:
308 define void @i32_sgt(i32 addrspace(1)* %out, i32 %a, i32 %b) {
310 %0 = icmp sgt i32 %a, %b
311 %1 = sext i1 %0 to i32
312 store i32 %1, i32 addrspace(1)* %out
316 ; FUNC-LABEL: {{^}}i32_sge:
319 define void @i32_sge(i32 addrspace(1)* %out, i32 %a, i32 %b) {
321 %0 = icmp sge i32 %a, %b
322 %1 = sext i1 %0 to i32
323 store i32 %1, i32 addrspace(1)* %out
327 ; FUNC-LABEL: {{^}}i32_slt:
330 define void @i32_slt(i32 addrspace(1)* %out, i32 %a, i32 %b) {
332 %0 = icmp slt i32 %a, %b
333 %1 = sext i1 %0 to i32
334 store i32 %1, i32 addrspace(1)* %out
338 ; FUNC-LABEL: {{^}}i32_sle:
341 define void @i32_sle(i32 addrspace(1)* %out, i32 %a, i32 %b) {
343 %0 = icmp sle i32 %a, %b
344 %1 = sext i1 %0 to i32
345 store i32 %1, i32 addrspace(1)* %out
349 ; FIXME: This does 4 compares
350 ; FUNC-LABEL: {{^}}v3i32_eq:
351 ; SI-DAG: v_cmp_eq_i32
352 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
353 ; SI-DAG: v_cmp_eq_i32
354 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
355 ; SI-DAG: v_cmp_eq_i32
356 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
358 define void @v3i32_eq(<3 x i32> addrspace(1)* %out, <3 x i32> addrspace(1)* %ptra, <3 x i32> addrspace(1)* %ptrb) {
359 %tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
360 %gep.a = getelementptr <3 x i32> addrspace(1)* %ptra, i32 %tid
361 %gep.b = getelementptr <3 x i32> addrspace(1)* %ptrb, i32 %tid
362 %gep.out = getelementptr <3 x i32> addrspace(1)* %out, i32 %tid
363 %a = load <3 x i32> addrspace(1)* %gep.a
364 %b = load <3 x i32> addrspace(1)* %gep.b
365 %cmp = icmp eq <3 x i32> %a, %b
366 %ext = sext <3 x i1> %cmp to <3 x i32>
367 store <3 x i32> %ext, <3 x i32> addrspace(1)* %gep.out
371 ; FUNC-LABEL: {{^}}v3i8_eq:
372 ; SI-DAG: v_cmp_eq_i32
373 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
374 ; SI-DAG: v_cmp_eq_i32
375 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
376 ; SI-DAG: v_cmp_eq_i32
377 ; SI-DAG: v_cndmask_b32_e64 {{v[0-9]+}}, 0, -1,
379 define void @v3i8_eq(<3 x i8> addrspace(1)* %out, <3 x i8> addrspace(1)* %ptra, <3 x i8> addrspace(1)* %ptrb) {
380 %tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
381 %gep.a = getelementptr <3 x i8> addrspace(1)* %ptra, i32 %tid
382 %gep.b = getelementptr <3 x i8> addrspace(1)* %ptrb, i32 %tid
383 %gep.out = getelementptr <3 x i8> addrspace(1)* %out, i32 %tid
384 %a = load <3 x i8> addrspace(1)* %gep.a
385 %b = load <3 x i8> addrspace(1)* %gep.b
386 %cmp = icmp eq <3 x i8> %a, %b
387 %ext = sext <3 x i1> %cmp to <3 x i8>
388 store <3 x i8> %ext, <3 x i8> addrspace(1)* %gep.out