blob: 8391860756a437588320f4d644a26e3a3b20a5fe [file] [log] [blame]
Dan Gohman36a09472009-09-08 23:54:48 +00001; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86 -mattr=sse2
Eli Friedman5ceb6662011-05-18 17:16:37 +00002; RUN: llc < %s -fast-isel -fast-isel-abort -mtriple=x86_64-apple-darwin10
Dan Gohmand3aedf42008-08-19 22:37:59 +00003
4; This tests very minimal fast-isel functionality.
5
Evan Cheng8b19e562008-09-03 06:44:39 +00006define i32* @foo(i32* %p, i32* %q, i32** %z) nounwind {
Dan Gohmand3aedf42008-08-19 22:37:59 +00007entry:
8 %r = load i32* %p
9 %s = load i32* %q
Dan Gohman7a0e6592008-08-21 17:25:26 +000010 %y = load i32** %z
Dan Gohmand3aedf42008-08-19 22:37:59 +000011 br label %fast
12
13fast:
Dan Gohmanbdedd442008-08-20 00:11:48 +000014 %t0 = add i32 %r, %s
15 %t1 = mul i32 %t0, %s
16 %t2 = sub i32 %t1, %s
17 %t3 = and i32 %t2, %s
Duncan Sands796248f2010-01-12 17:46:16 +000018 %t4 = xor i32 %t3, 3
Dan Gohmanbdedd442008-08-20 00:11:48 +000019 %t5 = xor i32 %t4, %s
Dan Gohmand5fe57d2008-08-21 01:41:07 +000020 %t6 = add i32 %t5, 2
Dan Gohman7a0e6592008-08-21 17:25:26 +000021 %t7 = getelementptr i32* %y, i32 1
22 %t8 = getelementptr i32* %t7, i32 %t6
Dan Gohmana61e73b2011-04-26 17:18:34 +000023 call void asm sideeffect "hello world", ""()
Dan Gohmand3aedf42008-08-19 22:37:59 +000024 br label %exit
25
26exit:
Dan Gohman7a0e6592008-08-21 17:25:26 +000027 ret i32* %t8
Dan Gohmand3aedf42008-08-19 22:37:59 +000028}
Dan Gohmanbdedd442008-08-20 00:11:48 +000029
Eli Friedman28b42af2011-05-18 00:00:10 +000030define void @bar(double* %p, double* %q) nounwind {
Dan Gohman8014e862008-08-20 00:23:20 +000031entry:
32 %r = load double* %p
33 %s = load double* %q
34 br label %fast
35
36fast:
Dan Gohmanae3a0be2009-06-04 22:49:04 +000037 %t0 = fadd double %r, %s
38 %t1 = fmul double %t0, %s
39 %t2 = fsub double %t1, %s
40 %t3 = fadd double %t2, 707.0
Dan Gohman8014e862008-08-20 00:23:20 +000041 br label %exit
42
43exit:
Eli Friedman28b42af2011-05-18 00:00:10 +000044 store double %t3, double* %q
45 ret void
Dan Gohman8014e862008-08-20 00:23:20 +000046}
47
Evan Cheng8b19e562008-09-03 06:44:39 +000048define i32 @cast() nounwind {
Owen Anderson6d0c25e2008-08-25 20:20:32 +000049entry:
50 %tmp2 = bitcast i32 0 to i32
51 ret i32 %tmp2
52}
Dan Gohman474d3b32009-03-13 23:53:06 +000053
Dan Gohman84023e02010-07-10 09:00:22 +000054define void @ptrtoint_i1(i8* %p, i1* %q) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000055 %t = ptrtoint i8* %p to i1
Dan Gohman84023e02010-07-10 09:00:22 +000056 store i1 %t, i1* %q
57 ret void
Dan Gohman474d3b32009-03-13 23:53:06 +000058}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000059define i8* @inttoptr_i1(i1 %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000060 %t = inttoptr i1 %p to i8*
61 ret i8* %t
62}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000063define i32 @ptrtoint_i32(i8* %p) nounwind {
64 %t = ptrtoint i8* %p to i32
65 ret i32 %t
66}
67define i8* @inttoptr_i32(i32 %p) nounwind {
68 %t = inttoptr i32 %p to i8*
69 ret i8* %t
70}
Dan Gohman7e7f06e2009-08-27 00:31:47 +000071
Eli Friedman28b42af2011-05-18 00:00:10 +000072define void @trunc_i32_i8(i32 %x, i8* %p) nounwind {
Dan Gohman5ce1bf92010-04-09 15:03:55 +000073 %tmp1 = trunc i32 %x to i8
Eli Friedman28b42af2011-05-18 00:00:10 +000074 store i8 %tmp1, i8* %p
75 ret void
Dan Gohman5ce1bf92010-04-09 15:03:55 +000076}
77
Eli Friedman28b42af2011-05-18 00:00:10 +000078define void @trunc_i16_i8(i16 signext %x, i8* %p) nounwind {
Dan Gohman5ce1bf92010-04-09 15:03:55 +000079 %tmp1 = trunc i16 %x to i8
Eli Friedman28b42af2011-05-18 00:00:10 +000080 store i8 %tmp1, i8* %p
81 ret void
Dan Gohman5ce1bf92010-04-09 15:03:55 +000082}
83
Eli Friedman28b42af2011-05-18 00:00:10 +000084define void @shl_i8(i8 %a, i8 %c, i8* %p) nounwind {
85 %tmp = shl i8 %a, %c
86 store i8 %tmp, i8* %p
87 ret void
Dan Gohman5ce1bf92010-04-09 15:03:55 +000088}
89
Eli Friedman28b42af2011-05-18 00:00:10 +000090define void @mul_i8(i8 %a, i8* %p) nounwind {
91 %tmp = mul i8 %a, 17
92 store i8 %tmp, i8* %p
93 ret void
Dan Gohman5ce1bf92010-04-09 15:03:55 +000094}
95
Dan Gohman84023e02010-07-10 09:00:22 +000096define void @load_store_i1(i1* %p, i1* %q) nounwind {
Bob Wilson02266e22010-07-09 16:37:18 +000097 %t = load i1* %p
Dan Gohman84023e02010-07-10 09:00:22 +000098 store i1 %t, i1* %q
99 ret void
Bob Wilson02266e22010-07-09 16:37:18 +0000100}
Chris Lattnerb686af02011-04-22 21:59:37 +0000101
102
103@crash_test1x = external global <2 x i32>, align 8
104
105define void @crash_test1() nounwind ssp {
106 %tmp = load <2 x i32>* @crash_test1x, align 8
107 %neg = xor <2 x i32> %tmp, <i32 -1, i32 -1>
108 ret void
109}
110