1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=NOAVX --check-prefix=SDAG
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=CHECK --check-prefix=NOAVX --check-prefix=FAST
4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 -mattr=avx | FileCheck %s --check-prefix=CHECK --check-prefix=FAST_AVX
5 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 -mattr=avx512f | FileCheck %s --check-prefix=CHECK --check-prefix=FAST_AVX
7 ; Test all the cmp predicates that can feed an integer conditional move.
9 define i64 @select_fcmp_false_cmov(double %a, double %b, i64 %c, i64 %d) {
10 ; CHECK-LABEL: select_fcmp_false_cmov:
12 ; CHECK-NEXT: movq %rsi, %rax
14 %1 = fcmp false double %a, %b
15 %2 = select i1 %1, i64 %c, i64 %d
19 define i64 @select_fcmp_oeq_cmov(double %a, double %b, i64 %c, i64 %d) {
20 ; SDAG-LABEL: select_fcmp_oeq_cmov:
22 ; SDAG-NEXT: movq %rdi, %rax
23 ; SDAG-NEXT: ucomisd %xmm1, %xmm0
24 ; SDAG-NEXT: cmovneq %rsi, %rax
25 ; SDAG-NEXT: cmovpq %rsi, %rax
28 ; FAST-LABEL: select_fcmp_oeq_cmov:
30 ; FAST-NEXT: movq %rdi, %rax
31 ; FAST-NEXT: ucomisd %xmm1, %xmm0
32 ; FAST-NEXT: setnp %cl
34 ; FAST-NEXT: testb %cl, %dl
35 ; FAST-NEXT: cmoveq %rsi, %rax
38 ; FAST_AVX-LABEL: select_fcmp_oeq_cmov:
40 ; FAST_AVX-NEXT: movq %rdi, %rax
41 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
42 ; FAST_AVX-NEXT: setnp %cl
43 ; FAST_AVX-NEXT: sete %dl
44 ; FAST_AVX-NEXT: testb %cl, %dl
45 ; FAST_AVX-NEXT: cmoveq %rsi, %rax
47 %1 = fcmp oeq double %a, %b
48 %2 = select i1 %1, i64 %c, i64 %d
52 define i64 @select_fcmp_ogt_cmov(double %a, double %b, i64 %c, i64 %d) {
53 ; NOAVX-LABEL: select_fcmp_ogt_cmov:
55 ; NOAVX-NEXT: movq %rdi, %rax
56 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
57 ; NOAVX-NEXT: cmovbeq %rsi, %rax
60 ; FAST_AVX-LABEL: select_fcmp_ogt_cmov:
62 ; FAST_AVX-NEXT: movq %rdi, %rax
63 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
64 ; FAST_AVX-NEXT: cmovbeq %rsi, %rax
66 %1 = fcmp ogt double %a, %b
67 %2 = select i1 %1, i64 %c, i64 %d
71 define i64 @select_fcmp_oge_cmov(double %a, double %b, i64 %c, i64 %d) {
72 ; NOAVX-LABEL: select_fcmp_oge_cmov:
74 ; NOAVX-NEXT: movq %rdi, %rax
75 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
76 ; NOAVX-NEXT: cmovbq %rsi, %rax
79 ; FAST_AVX-LABEL: select_fcmp_oge_cmov:
81 ; FAST_AVX-NEXT: movq %rdi, %rax
82 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
83 ; FAST_AVX-NEXT: cmovbq %rsi, %rax
85 %1 = fcmp oge double %a, %b
86 %2 = select i1 %1, i64 %c, i64 %d
90 define i64 @select_fcmp_olt_cmov(double %a, double %b, i64 %c, i64 %d) {
91 ; NOAVX-LABEL: select_fcmp_olt_cmov:
93 ; NOAVX-NEXT: movq %rdi, %rax
94 ; NOAVX-NEXT: ucomisd %xmm0, %xmm1
95 ; NOAVX-NEXT: cmovbeq %rsi, %rax
98 ; FAST_AVX-LABEL: select_fcmp_olt_cmov:
100 ; FAST_AVX-NEXT: movq %rdi, %rax
101 ; FAST_AVX-NEXT: vucomisd %xmm0, %xmm1
102 ; FAST_AVX-NEXT: cmovbeq %rsi, %rax
103 ; FAST_AVX-NEXT: retq
104 %1 = fcmp olt double %a, %b
105 %2 = select i1 %1, i64 %c, i64 %d
109 define i64 @select_fcmp_ole_cmov(double %a, double %b, i64 %c, i64 %d) {
110 ; NOAVX-LABEL: select_fcmp_ole_cmov:
112 ; NOAVX-NEXT: movq %rdi, %rax
113 ; NOAVX-NEXT: ucomisd %xmm0, %xmm1
114 ; NOAVX-NEXT: cmovbq %rsi, %rax
117 ; FAST_AVX-LABEL: select_fcmp_ole_cmov:
118 ; FAST_AVX: ## %bb.0:
119 ; FAST_AVX-NEXT: movq %rdi, %rax
120 ; FAST_AVX-NEXT: vucomisd %xmm0, %xmm1
121 ; FAST_AVX-NEXT: cmovbq %rsi, %rax
122 ; FAST_AVX-NEXT: retq
123 %1 = fcmp ole double %a, %b
124 %2 = select i1 %1, i64 %c, i64 %d
128 define i64 @select_fcmp_one_cmov(double %a, double %b, i64 %c, i64 %d) {
129 ; NOAVX-LABEL: select_fcmp_one_cmov:
131 ; NOAVX-NEXT: movq %rdi, %rax
132 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
133 ; NOAVX-NEXT: cmoveq %rsi, %rax
136 ; FAST_AVX-LABEL: select_fcmp_one_cmov:
137 ; FAST_AVX: ## %bb.0:
138 ; FAST_AVX-NEXT: movq %rdi, %rax
139 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
140 ; FAST_AVX-NEXT: cmoveq %rsi, %rax
141 ; FAST_AVX-NEXT: retq
142 %1 = fcmp one double %a, %b
143 %2 = select i1 %1, i64 %c, i64 %d
147 define i64 @select_fcmp_ord_cmov(double %a, double %b, i64 %c, i64 %d) {
148 ; NOAVX-LABEL: select_fcmp_ord_cmov:
150 ; NOAVX-NEXT: movq %rdi, %rax
151 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
152 ; NOAVX-NEXT: cmovpq %rsi, %rax
155 ; FAST_AVX-LABEL: select_fcmp_ord_cmov:
156 ; FAST_AVX: ## %bb.0:
157 ; FAST_AVX-NEXT: movq %rdi, %rax
158 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
159 ; FAST_AVX-NEXT: cmovpq %rsi, %rax
160 ; FAST_AVX-NEXT: retq
161 %1 = fcmp ord double %a, %b
162 %2 = select i1 %1, i64 %c, i64 %d
166 define i64 @select_fcmp_uno_cmov(double %a, double %b, i64 %c, i64 %d) {
167 ; NOAVX-LABEL: select_fcmp_uno_cmov:
169 ; NOAVX-NEXT: movq %rdi, %rax
170 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
171 ; NOAVX-NEXT: cmovnpq %rsi, %rax
174 ; FAST_AVX-LABEL: select_fcmp_uno_cmov:
175 ; FAST_AVX: ## %bb.0:
176 ; FAST_AVX-NEXT: movq %rdi, %rax
177 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
178 ; FAST_AVX-NEXT: cmovnpq %rsi, %rax
179 ; FAST_AVX-NEXT: retq
180 %1 = fcmp uno double %a, %b
181 %2 = select i1 %1, i64 %c, i64 %d
185 define i64 @select_fcmp_ueq_cmov(double %a, double %b, i64 %c, i64 %d) {
186 ; NOAVX-LABEL: select_fcmp_ueq_cmov:
188 ; NOAVX-NEXT: movq %rdi, %rax
189 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
190 ; NOAVX-NEXT: cmovneq %rsi, %rax
193 ; FAST_AVX-LABEL: select_fcmp_ueq_cmov:
194 ; FAST_AVX: ## %bb.0:
195 ; FAST_AVX-NEXT: movq %rdi, %rax
196 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
197 ; FAST_AVX-NEXT: cmovneq %rsi, %rax
198 ; FAST_AVX-NEXT: retq
199 %1 = fcmp ueq double %a, %b
200 %2 = select i1 %1, i64 %c, i64 %d
204 define i64 @select_fcmp_ugt_cmov(double %a, double %b, i64 %c, i64 %d) {
205 ; NOAVX-LABEL: select_fcmp_ugt_cmov:
207 ; NOAVX-NEXT: movq %rdi, %rax
208 ; NOAVX-NEXT: ucomisd %xmm0, %xmm1
209 ; NOAVX-NEXT: cmovaeq %rsi, %rax
212 ; FAST_AVX-LABEL: select_fcmp_ugt_cmov:
213 ; FAST_AVX: ## %bb.0:
214 ; FAST_AVX-NEXT: movq %rdi, %rax
215 ; FAST_AVX-NEXT: vucomisd %xmm0, %xmm1
216 ; FAST_AVX-NEXT: cmovaeq %rsi, %rax
217 ; FAST_AVX-NEXT: retq
218 %1 = fcmp ugt double %a, %b
219 %2 = select i1 %1, i64 %c, i64 %d
223 define i64 @select_fcmp_uge_cmov(double %a, double %b, i64 %c, i64 %d) {
224 ; NOAVX-LABEL: select_fcmp_uge_cmov:
226 ; NOAVX-NEXT: movq %rdi, %rax
227 ; NOAVX-NEXT: ucomisd %xmm0, %xmm1
228 ; NOAVX-NEXT: cmovaq %rsi, %rax
231 ; FAST_AVX-LABEL: select_fcmp_uge_cmov:
232 ; FAST_AVX: ## %bb.0:
233 ; FAST_AVX-NEXT: movq %rdi, %rax
234 ; FAST_AVX-NEXT: vucomisd %xmm0, %xmm1
235 ; FAST_AVX-NEXT: cmovaq %rsi, %rax
236 ; FAST_AVX-NEXT: retq
237 %1 = fcmp uge double %a, %b
238 %2 = select i1 %1, i64 %c, i64 %d
242 define i64 @select_fcmp_ult_cmov(double %a, double %b, i64 %c, i64 %d) {
243 ; NOAVX-LABEL: select_fcmp_ult_cmov:
245 ; NOAVX-NEXT: movq %rdi, %rax
246 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
247 ; NOAVX-NEXT: cmovaeq %rsi, %rax
250 ; FAST_AVX-LABEL: select_fcmp_ult_cmov:
251 ; FAST_AVX: ## %bb.0:
252 ; FAST_AVX-NEXT: movq %rdi, %rax
253 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
254 ; FAST_AVX-NEXT: cmovaeq %rsi, %rax
255 ; FAST_AVX-NEXT: retq
256 %1 = fcmp ult double %a, %b
257 %2 = select i1 %1, i64 %c, i64 %d
261 define i64 @select_fcmp_ule_cmov(double %a, double %b, i64 %c, i64 %d) {
262 ; NOAVX-LABEL: select_fcmp_ule_cmov:
264 ; NOAVX-NEXT: movq %rdi, %rax
265 ; NOAVX-NEXT: ucomisd %xmm1, %xmm0
266 ; NOAVX-NEXT: cmovaq %rsi, %rax
269 ; FAST_AVX-LABEL: select_fcmp_ule_cmov:
270 ; FAST_AVX: ## %bb.0:
271 ; FAST_AVX-NEXT: movq %rdi, %rax
272 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
273 ; FAST_AVX-NEXT: cmovaq %rsi, %rax
274 ; FAST_AVX-NEXT: retq
275 %1 = fcmp ule double %a, %b
276 %2 = select i1 %1, i64 %c, i64 %d
280 define i64 @select_fcmp_une_cmov(double %a, double %b, i64 %c, i64 %d) {
281 ; SDAG-LABEL: select_fcmp_une_cmov:
283 ; SDAG-NEXT: movq %rsi, %rax
284 ; SDAG-NEXT: ucomisd %xmm1, %xmm0
285 ; SDAG-NEXT: cmovneq %rdi, %rax
286 ; SDAG-NEXT: cmovpq %rdi, %rax
289 ; FAST-LABEL: select_fcmp_une_cmov:
291 ; FAST-NEXT: movq %rdi, %rax
292 ; FAST-NEXT: ucomisd %xmm1, %xmm0
293 ; FAST-NEXT: setp %cl
294 ; FAST-NEXT: setne %dl
295 ; FAST-NEXT: orb %cl, %dl
296 ; FAST-NEXT: cmoveq %rsi, %rax
299 ; FAST_AVX-LABEL: select_fcmp_une_cmov:
300 ; FAST_AVX: ## %bb.0:
301 ; FAST_AVX-NEXT: movq %rdi, %rax
302 ; FAST_AVX-NEXT: vucomisd %xmm1, %xmm0
303 ; FAST_AVX-NEXT: setp %cl
304 ; FAST_AVX-NEXT: setne %dl
305 ; FAST_AVX-NEXT: orb %cl, %dl
306 ; FAST_AVX-NEXT: cmoveq %rsi, %rax
307 ; FAST_AVX-NEXT: retq
308 %1 = fcmp une double %a, %b
309 %2 = select i1 %1, i64 %c, i64 %d
313 define i64 @select_fcmp_true_cmov(double %a, double %b, i64 %c, i64 %d) {
314 ; CHECK-LABEL: select_fcmp_true_cmov:
316 ; CHECK-NEXT: movq %rdi, %rax
318 %1 = fcmp true double %a, %b
319 %2 = select i1 %1, i64 %c, i64 %d
323 define i64 @select_icmp_eq_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
324 ; CHECK-LABEL: select_icmp_eq_cmov:
326 ; CHECK-NEXT: movq %rdx, %rax
327 ; CHECK-NEXT: cmpq %rsi, %rdi
328 ; CHECK-NEXT: cmovneq %rcx, %rax
330 %1 = icmp eq i64 %a, %b
331 %2 = select i1 %1, i64 %c, i64 %d
335 define i64 @select_icmp_ne_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
336 ; CHECK-LABEL: select_icmp_ne_cmov:
338 ; CHECK-NEXT: movq %rdx, %rax
339 ; CHECK-NEXT: cmpq %rsi, %rdi
340 ; CHECK-NEXT: cmoveq %rcx, %rax
342 %1 = icmp ne i64 %a, %b
343 %2 = select i1 %1, i64 %c, i64 %d
347 define i64 @select_icmp_ugt_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
348 ; CHECK-LABEL: select_icmp_ugt_cmov:
350 ; CHECK-NEXT: movq %rdx, %rax
351 ; CHECK-NEXT: cmpq %rsi, %rdi
352 ; CHECK-NEXT: cmovbeq %rcx, %rax
354 %1 = icmp ugt i64 %a, %b
355 %2 = select i1 %1, i64 %c, i64 %d
360 define i64 @select_icmp_uge_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
361 ; CHECK-LABEL: select_icmp_uge_cmov:
363 ; CHECK-NEXT: movq %rdx, %rax
364 ; CHECK-NEXT: cmpq %rsi, %rdi
365 ; CHECK-NEXT: cmovbq %rcx, %rax
367 %1 = icmp uge i64 %a, %b
368 %2 = select i1 %1, i64 %c, i64 %d
372 define i64 @select_icmp_ult_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
373 ; CHECK-LABEL: select_icmp_ult_cmov:
375 ; CHECK-NEXT: movq %rdx, %rax
376 ; CHECK-NEXT: cmpq %rsi, %rdi
377 ; CHECK-NEXT: cmovaeq %rcx, %rax
379 %1 = icmp ult i64 %a, %b
380 %2 = select i1 %1, i64 %c, i64 %d
384 define i64 @select_icmp_ule_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
385 ; CHECK-LABEL: select_icmp_ule_cmov:
387 ; CHECK-NEXT: movq %rdx, %rax
388 ; CHECK-NEXT: cmpq %rsi, %rdi
389 ; CHECK-NEXT: cmovaq %rcx, %rax
391 %1 = icmp ule i64 %a, %b
392 %2 = select i1 %1, i64 %c, i64 %d
396 define i64 @select_icmp_sgt_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
397 ; CHECK-LABEL: select_icmp_sgt_cmov:
399 ; CHECK-NEXT: movq %rdx, %rax
400 ; CHECK-NEXT: cmpq %rsi, %rdi
401 ; CHECK-NEXT: cmovleq %rcx, %rax
403 %1 = icmp sgt i64 %a, %b
404 %2 = select i1 %1, i64 %c, i64 %d
408 define i64 @select_icmp_sge_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
409 ; CHECK-LABEL: select_icmp_sge_cmov:
411 ; CHECK-NEXT: movq %rdx, %rax
412 ; CHECK-NEXT: cmpq %rsi, %rdi
413 ; CHECK-NEXT: cmovlq %rcx, %rax
415 %1 = icmp sge i64 %a, %b
416 %2 = select i1 %1, i64 %c, i64 %d
420 define i64 @select_icmp_slt_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
421 ; CHECK-LABEL: select_icmp_slt_cmov:
423 ; CHECK-NEXT: movq %rdx, %rax
424 ; CHECK-NEXT: cmpq %rsi, %rdi
425 ; CHECK-NEXT: cmovgeq %rcx, %rax
427 %1 = icmp slt i64 %a, %b
428 %2 = select i1 %1, i64 %c, i64 %d
432 define i64 @select_icmp_sle_cmov(i64 %a, i64 %b, i64 %c, i64 %d) {
433 ; CHECK-LABEL: select_icmp_sle_cmov:
435 ; CHECK-NEXT: movq %rdx, %rax
436 ; CHECK-NEXT: cmpq %rsi, %rdi
437 ; CHECK-NEXT: cmovgq %rcx, %rax
439 %1 = icmp sle i64 %a, %b
440 %2 = select i1 %1, i64 %c, i64 %d