1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
3 ; RUN: llc -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
4 ; TODO: enable when x87 is supported
5 ; llc -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86,GLOBAL-X86
6 ; RUN: llc -mtriple=x86_64-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
7 ; RUN: llc -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
8 ; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,GLOBAL-X64
10 define i1 @test_i1(i1 %a, i1 %b, i1 %c, i1 %pred0, i1 %pred1) {
12 ; X86: # %bb.0: # %entry
13 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
14 ; X86-NEXT: je .LBB0_1
15 ; X86-NEXT: # %bb.2: # %cond
16 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
17 ; X86-NEXT: je .LBB0_4
19 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
22 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
24 ; X86-NEXT: .LBB0_4: # %cond.false
25 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
29 ; X64: # %bb.0: # %entry
30 ; X64-NEXT: testb $1, %cl
31 ; X64-NEXT: je .LBB0_1
32 ; X64-NEXT: # %bb.2: # %cond
33 ; X64-NEXT: movl %esi, %eax
34 ; X64-NEXT: testb $1, %r8b
35 ; X64-NEXT: jne .LBB0_4
36 ; X64-NEXT: # %bb.3: # %cond.false
37 ; X64-NEXT: movl %edx, %eax
38 ; X64-NEXT: .LBB0_4: # %cond.end
39 ; X64-NEXT: # kill: def $al killed $al killed $eax
42 ; X64-NEXT: movl %edi, %eax
43 ; X64-NEXT: # kill: def $al killed $al killed $eax
46 br i1 %pred0, label %cond, label %cond.end
49 br i1 %pred1, label %cond.true, label %cond.false
58 %res = phi i1 [ %a, %entry ], [ %b, %cond.true ], [ %c, %cond.false ]
62 define i8 @test_i8(i8 %f, i8 %t, i1 %pred) {
64 ; X86: # %bb.0: # %entry
65 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
66 ; X86-NEXT: je .LBB1_2
68 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
70 ; X86-NEXT: .LBB1_2: # %cond.false
71 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
75 ; X64: # %bb.0: # %entry
76 ; X64-NEXT: testb $1, %dl
77 ; X64-NEXT: je .LBB1_2
79 ; X64-NEXT: movl %edi, %eax
80 ; X64-NEXT: # kill: def $al killed $al killed $eax
82 ; X64-NEXT: .LBB1_2: # %cond.false
83 ; X64-NEXT: movl %esi, %eax
84 ; X64-NEXT: # kill: def $al killed $al killed $eax
87 br i1 %pred, label %cond.true, label %cond.false
89 cond.true: ; preds = %entry
92 cond.false: ; preds = %entry
95 cond.end: ; preds = %cond.false, %cond.true
96 %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
100 define i16 @test_i16(i16 %f, i16 %t, i1 %pred) {
101 ; X86-LABEL: test_i16:
102 ; X86: # %bb.0: # %entry
103 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
104 ; X86-NEXT: je .LBB2_2
106 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
108 ; X86-NEXT: .LBB2_2: # %cond.false
109 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
112 ; X64-LABEL: test_i16:
113 ; X64: # %bb.0: # %entry
114 ; X64-NEXT: testb $1, %dl
115 ; X64-NEXT: je .LBB2_2
117 ; X64-NEXT: movl %edi, %eax
118 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
120 ; X64-NEXT: .LBB2_2: # %cond.false
121 ; X64-NEXT: movl %esi, %eax
122 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
125 br i1 %pred, label %cond.true, label %cond.false
127 cond.true: ; preds = %entry
130 cond.false: ; preds = %entry
133 cond.end: ; preds = %cond.false, %cond.true
134 %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
138 define i32 @test_i32(i32 %f, i32 %t, i1 %pred) {
139 ; X86-LABEL: test_i32:
140 ; X86: # %bb.0: # %entry
141 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
142 ; X86-NEXT: je .LBB3_2
144 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
146 ; X86-NEXT: .LBB3_2: # %cond.false
147 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
150 ; X64-LABEL: test_i32:
151 ; X64: # %bb.0: # %entry
152 ; X64-NEXT: movl %edi, %eax
153 ; X64-NEXT: testb $1, %dl
154 ; X64-NEXT: jne .LBB3_2
155 ; X64-NEXT: # %bb.1: # %cond.false
156 ; X64-NEXT: movl %esi, %eax
157 ; X64-NEXT: .LBB3_2: # %cond.end
160 br i1 %pred, label %cond.true, label %cond.false
162 cond.true: ; preds = %entry
165 cond.false: ; preds = %entry
168 cond.end: ; preds = %cond.false, %cond.true
169 %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
173 define i64 @test_i64(i64 %f, i64 %t, i1 %pred) {
174 ; X86-LABEL: test_i64:
175 ; X86: # %bb.0: # %entry
176 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
177 ; X86-NEXT: je .LBB4_2
179 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
180 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
182 ; X86-NEXT: .LBB4_2: # %cond.false
183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
184 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
187 ; X64-LABEL: test_i64:
188 ; X64: # %bb.0: # %entry
189 ; X64-NEXT: movq %rdi, %rax
190 ; X64-NEXT: testb $1, %dl
191 ; X64-NEXT: jne .LBB4_2
192 ; X64-NEXT: # %bb.1: # %cond.false
193 ; X64-NEXT: movq %rsi, %rax
194 ; X64-NEXT: .LBB4_2: # %cond.end
197 br i1 %pred, label %cond.true, label %cond.false
199 cond.true: ; preds = %entry
202 cond.false: ; preds = %entry
205 cond.end: ; preds = %cond.false, %cond.true
206 %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
210 define float @test_float(float %f, float %t, i1 %pred) {
211 ; X86-LABEL: test_float:
212 ; X86: # %bb.0: # %entry
213 ; X86-NEXT: flds {{[0-9]+}}(%esp)
214 ; X86-NEXT: flds {{[0-9]+}}(%esp)
215 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
216 ; X86-NEXT: jne .LBB5_2
217 ; X86-NEXT: # %bb.1: # %cond.false
218 ; X86-NEXT: fstp %st(0)
220 ; X86-NEXT: fxch %st(1)
221 ; X86-NEXT: .LBB5_2: # %cond.end
222 ; X86-NEXT: fstp %st(1)
225 ; X64-LABEL: test_float:
226 ; X64: # %bb.0: # %entry
227 ; X64-NEXT: testb $1, %dil
228 ; X64-NEXT: jne .LBB5_2
229 ; X64-NEXT: # %bb.1: # %cond.false
230 ; X64-NEXT: movaps %xmm1, %xmm0
231 ; X64-NEXT: .LBB5_2: # %cond.end
234 br i1 %pred, label %cond.true, label %cond.false
236 cond.true: ; preds = %entry
239 cond.false: ; preds = %entry
242 cond.end: ; preds = %cond.false, %cond.true
243 %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
247 define double @test_double(i32 %a, double %f, double %t, i1 %pred) {
248 ; X86-LABEL: test_double:
249 ; X86: # %bb.0: # %entry
250 ; X86-NEXT: fldl {{[0-9]+}}(%esp)
251 ; X86-NEXT: fldl {{[0-9]+}}(%esp)
252 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
253 ; X86-NEXT: jne .LBB6_2
254 ; X86-NEXT: # %bb.1: # %cond.false
255 ; X86-NEXT: fstp %st(0)
257 ; X86-NEXT: fxch %st(1)
258 ; X86-NEXT: .LBB6_2: # %cond.end
259 ; X86-NEXT: fstp %st(1)
262 ; X64-LABEL: test_double:
263 ; X64: # %bb.0: # %entry
264 ; X64-NEXT: testb $1, %sil
265 ; X64-NEXT: jne .LBB6_2
266 ; X64-NEXT: # %bb.1: # %cond.false
267 ; X64-NEXT: movaps %xmm1, %xmm0
268 ; X64-NEXT: .LBB6_2: # %cond.end
271 br i1 %pred, label %cond.true, label %cond.false
273 cond.true: ; preds = %entry
276 cond.false: ; preds = %entry
279 cond.end: ; preds = %cond.false, %cond.true
280 %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
284 define ptr @test_ptr(ptr %a, ptr %b, ptr %c, ptr %d, ptr %e, ptr %f, ptr %g, i1 %pred0, i1 %pred1, i1 %pred2) {
285 ; X86-LABEL: test_ptr:
286 ; X86: # %bb.0: # %entry
287 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
288 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
289 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
290 ; X86-NEXT: je .LBB7_6
291 ; X86-NEXT: # %bb.1: # %cond.true
292 ; X86-NEXT: testb $1, %cl
293 ; X86-NEXT: je .LBB7_3
295 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
297 ; X86-NEXT: .LBB7_6: # %cond.false
298 ; X86-NEXT: testb $1, %cl
299 ; X86-NEXT: je .LBB7_10
300 ; X86-NEXT: # %bb.7: # %cond.false.true
301 ; X86-NEXT: testb $1, %al
302 ; X86-NEXT: je .LBB7_9
304 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
306 ; X86-NEXT: .LBB7_3: # %cond.true.false
307 ; X86-NEXT: testb $1, %al
308 ; X86-NEXT: je .LBB7_5
310 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
312 ; X86-NEXT: .LBB7_10: # %cond.false.false
313 ; X86-NEXT: testb $1, %al
314 ; X86-NEXT: je .LBB7_12
315 ; X86-NEXT: # %bb.11:
316 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
318 ; X86-NEXT: .LBB7_9: # %cond.false.true.false
319 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
321 ; X86-NEXT: .LBB7_5: # %cond.true.false.false
322 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
324 ; X86-NEXT: .LBB7_12: # %cond.false.false.false
325 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
328 ; DAG-X64-LABEL: test_ptr:
329 ; DAG-X64: # %bb.0: # %entry
330 ; DAG-X64-NEXT: movq %rdi, %rax
331 ; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %edi
332 ; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %r10d
333 ; DAG-X64-NEXT: testb $1, {{[0-9]+}}(%rsp)
334 ; DAG-X64-NEXT: je .LBB7_4
335 ; DAG-X64-NEXT: # %bb.1: # %cond.true
336 ; DAG-X64-NEXT: testb $1, %r10b
337 ; DAG-X64-NEXT: jne .LBB7_9
338 ; DAG-X64-NEXT: # %bb.2: # %cond.true.false
339 ; DAG-X64-NEXT: testb $1, %dil
340 ; DAG-X64-NEXT: movq %rsi, %rax
341 ; DAG-X64-NEXT: jne .LBB7_9
342 ; DAG-X64-NEXT: # %bb.3: # %cond.true.false.false
343 ; DAG-X64-NEXT: movq %rdx, %rax
345 ; DAG-X64-NEXT: .LBB7_4: # %cond.false
346 ; DAG-X64-NEXT: testb $1, %r10b
347 ; DAG-X64-NEXT: je .LBB7_7
348 ; DAG-X64-NEXT: # %bb.5: # %cond.false.true
349 ; DAG-X64-NEXT: testb $1, %dil
350 ; DAG-X64-NEXT: movq %rcx, %rax
351 ; DAG-X64-NEXT: jne .LBB7_9
352 ; DAG-X64-NEXT: # %bb.6: # %cond.false.true.false
353 ; DAG-X64-NEXT: movq %r8, %rax
355 ; DAG-X64-NEXT: .LBB7_7: # %cond.false.false
356 ; DAG-X64-NEXT: testb $1, %dil
357 ; DAG-X64-NEXT: movq %r9, %rax
358 ; DAG-X64-NEXT: jne .LBB7_9
359 ; DAG-X64-NEXT: # %bb.8: # %cond.false.false.false
360 ; DAG-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
361 ; DAG-X64-NEXT: .LBB7_9: # %cond.end
364 ; GLOBAL-X64-LABEL: test_ptr:
365 ; GLOBAL-X64: # %bb.0: # %entry
366 ; GLOBAL-X64-NEXT: movq %rdi, %rax
367 ; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r11d
368 ; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r10d
369 ; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %edi
370 ; GLOBAL-X64-NEXT: testb $1, %r11b
371 ; GLOBAL-X64-NEXT: je .LBB7_4
372 ; GLOBAL-X64-NEXT: # %bb.1: # %cond.true
373 ; GLOBAL-X64-NEXT: testb $1, %r10b
374 ; GLOBAL-X64-NEXT: jne .LBB7_9
375 ; GLOBAL-X64-NEXT: # %bb.2: # %cond.true.false
376 ; GLOBAL-X64-NEXT: testb $1, %dil
377 ; GLOBAL-X64-NEXT: movq %rsi, %rax
378 ; GLOBAL-X64-NEXT: jne .LBB7_9
379 ; GLOBAL-X64-NEXT: # %bb.3: # %cond.true.false.false
380 ; GLOBAL-X64-NEXT: movq %rdx, %rax
381 ; GLOBAL-X64-NEXT: retq
382 ; GLOBAL-X64-NEXT: .LBB7_4: # %cond.false
383 ; GLOBAL-X64-NEXT: testb $1, %r10b
384 ; GLOBAL-X64-NEXT: je .LBB7_7
385 ; GLOBAL-X64-NEXT: # %bb.5: # %cond.false.true
386 ; GLOBAL-X64-NEXT: testb $1, %dil
387 ; GLOBAL-X64-NEXT: movq %rcx, %rax
388 ; GLOBAL-X64-NEXT: jne .LBB7_9
389 ; GLOBAL-X64-NEXT: # %bb.6: # %cond.false.true.false
390 ; GLOBAL-X64-NEXT: movq %r8, %rax
391 ; GLOBAL-X64-NEXT: retq
392 ; GLOBAL-X64-NEXT: .LBB7_7: # %cond.false.false
393 ; GLOBAL-X64-NEXT: testb $1, %dil
394 ; GLOBAL-X64-NEXT: movq %r9, %rax
395 ; GLOBAL-X64-NEXT: jne .LBB7_9
396 ; GLOBAL-X64-NEXT: # %bb.8: # %cond.false.false.false
397 ; GLOBAL-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
398 ; GLOBAL-X64-NEXT: .LBB7_9: # %cond.end
399 ; GLOBAL-X64-NEXT: retq
401 br i1 %pred0, label %cond.true, label %cond.false
404 br i1 %pred1, label %cond.end, label %cond.true.false
407 br i1 %pred2, label %cond.true.false.true, label %cond.true.false.false
409 cond.true.false.true:
412 cond.true.false.false:
416 br i1 %pred1, label %cond.false.true, label %cond.false.false
419 br i1 %pred2, label %cond.false.true.true, label %cond.false.true.false
421 cond.false.true.true:
424 cond.false.true.false:
428 br i1 %pred2, label %cond.false.false.true, label %cond.false.false.false
430 cond.false.false.true:
433 cond.false.false.false:
437 %res = phi ptr [ %a, %cond.true ], [ %b, %cond.true.false.true ], [ %c, %cond.true.false.false ], [ %d, %cond.false.true.true ], [ %e, %cond.false.true.false ], [ %f, %cond.false.false.true ], [ %g, %cond.false.false.false ]
441 define x86_fp80 @test_fp80(x86_fp80 %f, x86_fp80 %t, i1 %pred) {
442 ; X86-LABEL: test_fp80:
443 ; X86: # %bb.0: # %entry
444 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
445 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
446 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
447 ; X86-NEXT: jne .LBB8_2
448 ; X86-NEXT: # %bb.1: # %cond.false
449 ; X86-NEXT: fstp %st(0)
451 ; X86-NEXT: fxch %st(1)
452 ; X86-NEXT: .LBB8_2: # %cond.end
453 ; X86-NEXT: fstp %st(1)
456 ; DAG-X64-LABEL: test_fp80:
457 ; DAG-X64: # %bb.0: # %entry
458 ; DAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
459 ; DAG-X64-NEXT: fldt {{[0-9]+}}(%rsp)
460 ; DAG-X64-NEXT: testb $1, %dil
461 ; DAG-X64-NEXT: jne .LBB8_2
462 ; DAG-X64-NEXT: # %bb.1: # %cond.false
463 ; DAG-X64-NEXT: fstp %st(0)
465 ; DAG-X64-NEXT: fxch %st(1)
466 ; DAG-X64-NEXT: .LBB8_2: # %cond.end
467 ; DAG-X64-NEXT: fstp %st(1)
470 ; GLOBAL-X64-LABEL: test_fp80:
471 ; GLOBAL-X64: # %bb.0: # %entry
472 ; GLOBAL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
473 ; GLOBAL-X64-NEXT: fldt {{[0-9]+}}(%rsp)
474 ; GLOBAL-X64-NEXT: testb $1, %dil
475 ; GLOBAL-X64-NEXT: jne .LBB8_2
476 ; GLOBAL-X64-NEXT: # %bb.1: # %cond.false
477 ; GLOBAL-X64-NEXT: fstp %st(1)
478 ; GLOBAL-X64-NEXT: fldz
479 ; GLOBAL-X64-NEXT: .LBB8_2: # %cond.end
480 ; GLOBAL-X64-NEXT: fstp %st(0)
481 ; GLOBAL-X64-NEXT: retq
483 br i1 %pred, label %cond.true, label %cond.false
485 cond.true: ; preds = %entry
488 cond.false: ; preds = %entry
491 cond.end: ; preds = %cond.false, %cond.true
492 %cond = phi x86_fp80 [ %f, %cond.true ], [ %t, %cond.false ]