blob: 3d26ae7018b573d180e45e5dd662ba1aa3677927 [file] [log] [blame]
Dan Gohman36a09472009-09-08 23:54:48 +00001; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86 -mattr=sse2
Dan Gohman5ce1bf92010-04-09 15:03:55 +00002; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86-64
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 Gohmand3aedf42008-08-19 22:37:59 +000023 br label %exit
24
25exit:
Dan Gohman7a0e6592008-08-21 17:25:26 +000026 ret i32* %t8
Dan Gohmand3aedf42008-08-19 22:37:59 +000027}
Dan Gohmanbdedd442008-08-20 00:11:48 +000028
Evan Cheng8b19e562008-09-03 06:44:39 +000029define double @bar(double* %p, double* %q) nounwind {
Dan Gohman8014e862008-08-20 00:23:20 +000030entry:
31 %r = load double* %p
32 %s = load double* %q
33 br label %fast
34
35fast:
Dan Gohmanae3a0be2009-06-04 22:49:04 +000036 %t0 = fadd double %r, %s
37 %t1 = fmul double %t0, %s
38 %t2 = fsub double %t1, %s
39 %t3 = fadd double %t2, 707.0
Dan Gohman8014e862008-08-20 00:23:20 +000040 br label %exit
41
42exit:
Dan Gohman10df0fa2008-08-27 01:09:54 +000043 ret double %t3
Dan Gohman8014e862008-08-20 00:23:20 +000044}
45
Evan Cheng8b19e562008-09-03 06:44:39 +000046define i32 @cast() nounwind {
Owen Anderson6d0c25e2008-08-25 20:20:32 +000047entry:
48 %tmp2 = bitcast i32 0 to i32
49 ret i32 %tmp2
50}
Dan Gohman474d3b32009-03-13 23:53:06 +000051
Dan Gohmand00d2fe2009-03-13 23:54:51 +000052define i1 @ptrtoint_i1(i8* %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000053 %t = ptrtoint i8* %p to i1
54 ret i1 %t
55}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000056define i8* @inttoptr_i1(i1 %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000057 %t = inttoptr i1 %p to i8*
58 ret i8* %t
59}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000060define i32 @ptrtoint_i32(i8* %p) nounwind {
61 %t = ptrtoint i8* %p to i32
62 ret i32 %t
63}
64define i8* @inttoptr_i32(i32 %p) nounwind {
65 %t = inttoptr i32 %p to i8*
66 ret i8* %t
67}
Dan Gohman7e7f06e2009-08-27 00:31:47 +000068
Dan Gohman5ce1bf92010-04-09 15:03:55 +000069define i8 @trunc_i32_i8(i32 %x) signext nounwind {
70 %tmp1 = trunc i32 %x to i8
71 ret i8 %tmp1
72}
73
74define i8 @trunc_i16_i8(i16 signext %x) signext nounwind {
75 %tmp1 = trunc i16 %x to i8
76 ret i8 %tmp1
77}
78
79define i8 @shl_i8(i8 %a, i8 %c) nounwind {
80 %tmp = shl i8 %a, %c
81 ret i8 %tmp
82}
83
84define i8 @mul_i8(i8 %a) nounwind {
85 %tmp = mul i8 %a, 17
86 ret i8 %tmp
87}
88
Dan Gohman7e7f06e2009-08-27 00:31:47 +000089define void @store_i1(i1* %p, i1 %t) nounwind {
90 store i1 %t, i1* %p
91 ret void
92}
93define i1 @load_i1(i1* %p) nounwind {
94 %t = load i1* %p
95 ret i1 %t
96}