1 ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
2 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
4 ;; These tests should run for all targets
6 ;;===-- Basic instruction selection tests ---------------------------------===;;
11 define i64 @icmp_eq_i64(i64 %a, i64 %b) {
12 ; CHECK: setp.eq.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
13 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
15 %cmp = icmp eq i64 %a, %b
16 %ret = zext i1 %cmp to i64
20 define i64 @icmp_ne_i64(i64 %a, i64 %b) {
21 ; CHECK: setp.ne.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
22 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
24 %cmp = icmp ne i64 %a, %b
25 %ret = zext i1 %cmp to i64
29 define i64 @icmp_ugt_i64(i64 %a, i64 %b) {
30 ; CHECK: setp.gt.u64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
31 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
33 %cmp = icmp ugt i64 %a, %b
34 %ret = zext i1 %cmp to i64
38 define i64 @icmp_uge_i64(i64 %a, i64 %b) {
39 ; CHECK: setp.ge.u64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
40 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
42 %cmp = icmp uge i64 %a, %b
43 %ret = zext i1 %cmp to i64
47 define i64 @icmp_ult_i64(i64 %a, i64 %b) {
48 ; CHECK: setp.lt.u64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
49 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
51 %cmp = icmp ult i64 %a, %b
52 %ret = zext i1 %cmp to i64
56 define i64 @icmp_ule_i64(i64 %a, i64 %b) {
57 ; CHECK: setp.le.u64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
58 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
60 %cmp = icmp ule i64 %a, %b
61 %ret = zext i1 %cmp to i64
65 define i64 @icmp_sgt_i64(i64 %a, i64 %b) {
66 ; CHECK: setp.gt.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
67 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
69 %cmp = icmp sgt i64 %a, %b
70 %ret = zext i1 %cmp to i64
74 define i64 @icmp_sge_i64(i64 %a, i64 %b) {
75 ; CHECK: setp.ge.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
76 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
78 %cmp = icmp sge i64 %a, %b
79 %ret = zext i1 %cmp to i64
83 define i64 @icmp_slt_i64(i64 %a, i64 %b) {
84 ; CHECK: setp.lt.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
85 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
87 %cmp = icmp slt i64 %a, %b
88 %ret = zext i1 %cmp to i64
92 define i64 @icmp_sle_i64(i64 %a, i64 %b) {
93 ; CHECK: setp.le.s64 %p[[P0:[0-9]+]], %rd{{[0-9]+}}, %rd{{[0-9]+}}
94 ; CHECK: selp.u64 %rd{{[0-9]+}}, 1, 0, %p[[P0]]
96 %cmp = icmp sle i64 %a, %b
97 %ret = zext i1 %cmp to i64
103 define i32 @icmp_eq_i32(i32 %a, i32 %b) {
104 ; CHECK: setp.eq.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
105 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
107 %cmp = icmp eq i32 %a, %b
108 %ret = zext i1 %cmp to i32
112 define i32 @icmp_ne_i32(i32 %a, i32 %b) {
113 ; CHECK: setp.ne.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
114 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
116 %cmp = icmp ne i32 %a, %b
117 %ret = zext i1 %cmp to i32
121 define i32 @icmp_ugt_i32(i32 %a, i32 %b) {
122 ; CHECK: setp.gt.u32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
123 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
125 %cmp = icmp ugt i32 %a, %b
126 %ret = zext i1 %cmp to i32
130 define i32 @icmp_uge_i32(i32 %a, i32 %b) {
131 ; CHECK: setp.ge.u32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
132 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
134 %cmp = icmp uge i32 %a, %b
135 %ret = zext i1 %cmp to i32
139 define i32 @icmp_ult_i32(i32 %a, i32 %b) {
140 ; CHECK: setp.lt.u32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
141 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
143 %cmp = icmp ult i32 %a, %b
144 %ret = zext i1 %cmp to i32
148 define i32 @icmp_ule_i32(i32 %a, i32 %b) {
149 ; CHECK: setp.le.u32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
150 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
152 %cmp = icmp ule i32 %a, %b
153 %ret = zext i1 %cmp to i32
157 define i32 @icmp_sgt_i32(i32 %a, i32 %b) {
158 ; CHECK: setp.gt.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
159 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
161 %cmp = icmp sgt i32 %a, %b
162 %ret = zext i1 %cmp to i32
166 define i32 @icmp_sge_i32(i32 %a, i32 %b) {
167 ; CHECK: setp.ge.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
168 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
170 %cmp = icmp sge i32 %a, %b
171 %ret = zext i1 %cmp to i32
175 define i32 @icmp_slt_i32(i32 %a, i32 %b) {
176 ; CHECK: setp.lt.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
177 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
179 %cmp = icmp slt i32 %a, %b
180 %ret = zext i1 %cmp to i32
184 define i32 @icmp_sle_i32(i32 %a, i32 %b) {
185 ; CHECK: setp.le.s32 %p[[P0:[0-9]+]], %r{{[0-9]+}}, %r{{[0-9]+}}
186 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
188 %cmp = icmp sle i32 %a, %b
189 %ret = zext i1 %cmp to i32
196 define i16 @icmp_eq_i16(i16 %a, i16 %b) {
197 ; CHECK: setp.eq.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
198 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
200 %cmp = icmp eq i16 %a, %b
201 %ret = zext i1 %cmp to i16
205 define i16 @icmp_ne_i16(i16 %a, i16 %b) {
206 ; CHECK: setp.ne.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
207 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
209 %cmp = icmp ne i16 %a, %b
210 %ret = zext i1 %cmp to i16
214 define i16 @icmp_ugt_i16(i16 %a, i16 %b) {
215 ; CHECK: setp.gt.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
216 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
218 %cmp = icmp ugt i16 %a, %b
219 %ret = zext i1 %cmp to i16
223 define i16 @icmp_uge_i16(i16 %a, i16 %b) {
224 ; CHECK: setp.ge.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
225 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
227 %cmp = icmp uge i16 %a, %b
228 %ret = zext i1 %cmp to i16
232 define i16 @icmp_ult_i16(i16 %a, i16 %b) {
233 ; CHECK: setp.lt.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
234 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
236 %cmp = icmp ult i16 %a, %b
237 %ret = zext i1 %cmp to i16
241 define i16 @icmp_ule_i16(i16 %a, i16 %b) {
242 ; CHECK: setp.le.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
243 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
245 %cmp = icmp ule i16 %a, %b
246 %ret = zext i1 %cmp to i16
250 define i16 @icmp_sgt_i16(i16 %a, i16 %b) {
251 ; CHECK: setp.gt.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
252 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
254 %cmp = icmp sgt i16 %a, %b
255 %ret = zext i1 %cmp to i16
259 define i16 @icmp_sge_i16(i16 %a, i16 %b) {
260 ; CHECK: setp.ge.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
261 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
263 %cmp = icmp sge i16 %a, %b
264 %ret = zext i1 %cmp to i16
268 define i16 @icmp_slt_i16(i16 %a, i16 %b) {
269 ; CHECK: setp.lt.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
270 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
272 %cmp = icmp slt i16 %a, %b
273 %ret = zext i1 %cmp to i16
277 define i16 @icmp_sle_i16(i16 %a, i16 %b) {
278 ; CHECK: setp.le.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
279 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
281 %cmp = icmp sle i16 %a, %b
282 %ret = zext i1 %cmp to i16
289 define i8 @icmp_eq_i8(i8 %a, i8 %b) {
290 ; Comparison happens in 16-bit
291 ; CHECK: setp.eq.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
292 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
294 %cmp = icmp eq i8 %a, %b
295 %ret = zext i1 %cmp to i8
299 define i8 @icmp_ne_i8(i8 %a, i8 %b) {
300 ; Comparison happens in 16-bit
301 ; CHECK: setp.ne.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
302 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
304 %cmp = icmp ne i8 %a, %b
305 %ret = zext i1 %cmp to i8
309 define i8 @icmp_ugt_i8(i8 %a, i8 %b) {
310 ; Comparison happens in 16-bit
311 ; CHECK: setp.gt.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
312 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
314 %cmp = icmp ugt i8 %a, %b
315 %ret = zext i1 %cmp to i8
319 define i8 @icmp_uge_i8(i8 %a, i8 %b) {
320 ; Comparison happens in 16-bit
321 ; CHECK: setp.ge.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
322 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
324 %cmp = icmp uge i8 %a, %b
325 %ret = zext i1 %cmp to i8
329 define i8 @icmp_ult_i8(i8 %a, i8 %b) {
330 ; Comparison happens in 16-bit
331 ; CHECK: setp.lt.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
332 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
334 %cmp = icmp ult i8 %a, %b
335 %ret = zext i1 %cmp to i8
339 define i8 @icmp_ule_i8(i8 %a, i8 %b) {
340 ; Comparison happens in 16-bit
341 ; CHECK: setp.le.u16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
342 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
344 %cmp = icmp ule i8 %a, %b
345 %ret = zext i1 %cmp to i8
349 define i8 @icmp_sgt_i8(i8 %a, i8 %b) {
350 ; Comparison happens in 16-bit
351 ; CHECK: setp.gt.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
352 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
354 %cmp = icmp sgt i8 %a, %b
355 %ret = zext i1 %cmp to i8
359 define i8 @icmp_sge_i8(i8 %a, i8 %b) {
360 ; Comparison happens in 16-bit
361 ; CHECK: setp.ge.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
362 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
364 %cmp = icmp sge i8 %a, %b
365 %ret = zext i1 %cmp to i8
369 define i8 @icmp_slt_i8(i8 %a, i8 %b) {
370 ; Comparison happens in 16-bit
371 ; CHECK: setp.lt.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
372 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
374 %cmp = icmp slt i8 %a, %b
375 %ret = zext i1 %cmp to i8
379 define i8 @icmp_sle_i8(i8 %a, i8 %b) {
380 ; Comparison happens in 16-bit
381 ; CHECK: setp.le.s16 %p[[P0:[0-9]+]], %rs{{[0-9]+}}, %rs{{[0-9]+}}
382 ; CHECK: selp.u32 %r{{[0-9]+}}, 1, 0, %p[[P0]]
384 %cmp = icmp sle i8 %a, %b
385 %ret = zext i1 %cmp to i8