blob: ef5e353e9f9fbfa1dbcb2cc5d3f6e948e727d174 [file] [log] [blame]
Chris Lattner40755462010-10-08 05:12:30 +00001; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -show-mc-encoding | FileCheck %s
Evan Cheng23f84972006-09-11 02:33:29 +00002
Chris Lattner48b03bc2010-10-08 05:02:29 +00003define i32 @test1(i32 %X, i32* %y) nounwind {
Tanya Lattner33eefff2008-02-21 07:42:26 +00004 %tmp = load i32* %y ; <i32> [#uses=1]
5 %tmp.upgrd.1 = icmp eq i32 %tmp, 0 ; <i1> [#uses=1]
6 br i1 %tmp.upgrd.1, label %ReturnBlock, label %cond_true
Evan Cheng23f84972006-09-11 02:33:29 +00007
Tanya Lattner33eefff2008-02-21 07:42:26 +00008cond_true: ; preds = %0
9 ret i32 1
Evan Cheng23f84972006-09-11 02:33:29 +000010
Tanya Lattner33eefff2008-02-21 07:42:26 +000011ReturnBlock: ; preds = %0
12 ret i32 0
Chris Lattner48b03bc2010-10-08 05:02:29 +000013; CHECK: test1:
14; CHECK: cmpl $0, (%rsi)
Evan Cheng23f84972006-09-11 02:33:29 +000015}
16
Chris Lattner48b03bc2010-10-08 05:02:29 +000017define i32 @test2(i32 %X, i32* %y) nounwind {
Tanya Lattner33eefff2008-02-21 07:42:26 +000018 %tmp = load i32* %y ; <i32> [#uses=1]
19 %tmp1 = shl i32 %tmp, 3 ; <i32> [#uses=1]
20 %tmp1.upgrd.2 = icmp eq i32 %tmp1, 0 ; <i1> [#uses=1]
21 br i1 %tmp1.upgrd.2, label %ReturnBlock, label %cond_true
Evan Cheng23f84972006-09-11 02:33:29 +000022
Tanya Lattner33eefff2008-02-21 07:42:26 +000023cond_true: ; preds = %0
24 ret i32 1
Evan Cheng23f84972006-09-11 02:33:29 +000025
Tanya Lattner33eefff2008-02-21 07:42:26 +000026ReturnBlock: ; preds = %0
27 ret i32 0
Chris Lattner48b03bc2010-10-08 05:02:29 +000028; CHECK: test2:
29; CHECK: movl (%rsi), %eax
30; CHECK: shll $3, %eax
31; CHECK: testl %eax, %eax
Evan Cheng23f84972006-09-11 02:33:29 +000032}
Chris Lattner4a263182010-10-08 05:04:58 +000033
34define i64 @test3(i64 %x) nounwind {
35 %t = icmp eq i64 %x, 0
36 %r = zext i1 %t to i64
37 ret i64 %r
38; CHECK: test3:
39; CHECK: testq %rdi, %rdi
40; CHECK: sete %al
Bill Wendlingd336de32011-04-14 01:46:37 +000041; CHECK: movzbl %al, %eax
Chris Lattner4a263182010-10-08 05:04:58 +000042; CHECK: ret
43}
44
45define i64 @test4(i64 %x) nounwind {
46 %t = icmp slt i64 %x, 1
47 %r = zext i1 %t to i64
48 ret i64 %r
49; CHECK: test4:
50; CHECK: testq %rdi, %rdi
51; CHECK: setle %al
Bill Wendlingd336de32011-04-14 01:46:37 +000052; CHECK: movzbl %al, %eax
Chris Lattner4a263182010-10-08 05:04:58 +000053; CHECK: ret
54}
55
56
57define i32 @test5(double %A) nounwind {
58 entry:
59 %tmp2 = fcmp ogt double %A, 1.500000e+02; <i1> [#uses=1]
60 %tmp5 = fcmp ult double %A, 7.500000e+01; <i1> [#uses=1]
61 %bothcond = or i1 %tmp2, %tmp5; <i1> [#uses=1]
62 br i1 %bothcond, label %bb8, label %bb12
63
64 bb8:; preds = %entry
65 %tmp9 = tail call i32 (...)* @foo( ) nounwind ; <i32> [#uses=1]
66 ret i32 %tmp9
67
68 bb12:; preds = %entry
69 ret i32 32
70; CHECK: test5:
71; CHECK: ucomisd LCPI4_0(%rip), %xmm0
72; CHECK: ucomisd LCPI4_1(%rip), %xmm0
73}
74
75declare i32 @foo(...)
Chris Lattner40755462010-10-08 05:12:30 +000076
77define i32 @test6() nounwind align 2 {
78 %A = alloca {i64, i64}, align 8
79 %B = getelementptr inbounds {i64, i64}* %A, i64 0, i32 1
80 %C = load i64* %B
81 %D = icmp eq i64 %C, 0
82 br i1 %D, label %T, label %F
83T:
84 ret i32 1
85
86F:
87 ret i32 0
88; CHECK: test6:
89; CHECK: cmpq $0, -8(%rsp)
90; CHECK: encoding: [0x48,0x83,0x7c,0x24,0xf8,0x00]
91}
92