blob: 177c06b45dcd2bf49d62ee87e2fb96eae2f879e6 [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 Gohman84023e02010-07-10 09:00:22 +000052define void @ptrtoint_i1(i8* %p, i1* %q) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000053 %t = ptrtoint i8* %p to i1
Dan Gohman84023e02010-07-10 09:00:22 +000054 store i1 %t, i1* %q
55 ret void
Dan Gohman474d3b32009-03-13 23:53:06 +000056}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000057define i8* @inttoptr_i1(i1 %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000058 %t = inttoptr i1 %p to i8*
59 ret i8* %t
60}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000061define i32 @ptrtoint_i32(i8* %p) nounwind {
62 %t = ptrtoint i8* %p to i32
63 ret i32 %t
64}
65define i8* @inttoptr_i32(i32 %p) nounwind {
66 %t = inttoptr i32 %p to i8*
67 ret i8* %t
68}
Dan Gohman7e7f06e2009-08-27 00:31:47 +000069
Dan Gohman5ce1bf92010-04-09 15:03:55 +000070define i8 @trunc_i32_i8(i32 %x) signext nounwind {
71 %tmp1 = trunc i32 %x to i8
72 ret i8 %tmp1
73}
74
75define i8 @trunc_i16_i8(i16 signext %x) signext nounwind {
76 %tmp1 = trunc i16 %x to i8
77 ret i8 %tmp1
78}
79
80define i8 @shl_i8(i8 %a, i8 %c) nounwind {
81 %tmp = shl i8 %a, %c
82 ret i8 %tmp
83}
84
85define i8 @mul_i8(i8 %a) nounwind {
86 %tmp = mul i8 %a, 17
87 ret i8 %tmp
88}
89
Dan Gohman84023e02010-07-10 09:00:22 +000090define void @load_store_i1(i1* %p, i1* %q) nounwind {
Bob Wilson02266e22010-07-09 16:37:18 +000091 %t = load i1* %p
Dan Gohman84023e02010-07-10 09:00:22 +000092 store i1 %t, i1* %q
93 ret void
Bob Wilson02266e22010-07-09 16:37:18 +000094}