blob: a9a016b7d0f34d4f4a395bef137037ba6fb91e87 [file] [log] [blame]
Dan Gohman474d3b32009-03-13 23:53:06 +00001; RUN: llvm-as < %s | llc -fast-isel -fast-isel-abort -march=x86 -mattr=sse2
Dan Gohmand3aedf42008-08-19 22:37:59 +00002
3; This tests very minimal fast-isel functionality.
4
Evan Cheng8b19e562008-09-03 06:44:39 +00005define i32* @foo(i32* %p, i32* %q, i32** %z) nounwind {
Dan Gohmand3aedf42008-08-19 22:37:59 +00006entry:
7 %r = load i32* %p
8 %s = load i32* %q
Dan Gohman7a0e6592008-08-21 17:25:26 +00009 %y = load i32** %z
Dan Gohmand3aedf42008-08-19 22:37:59 +000010 br label %fast
11
12fast:
Dan Gohmanbdedd442008-08-20 00:11:48 +000013 %t0 = add i32 %r, %s
14 %t1 = mul i32 %t0, %s
15 %t2 = sub i32 %t1, %s
16 %t3 = and i32 %t2, %s
17 %t4 = or i32 %t3, %s
18 %t5 = xor i32 %t4, %s
Dan Gohmand5fe57d2008-08-21 01:41:07 +000019 %t6 = add i32 %t5, 2
Dan Gohman7a0e6592008-08-21 17:25:26 +000020 %t7 = getelementptr i32* %y, i32 1
21 %t8 = getelementptr i32* %t7, i32 %t6
Dan Gohmand3aedf42008-08-19 22:37:59 +000022 br label %exit
23
24exit:
Dan Gohman7a0e6592008-08-21 17:25:26 +000025 ret i32* %t8
Dan Gohmand3aedf42008-08-19 22:37:59 +000026}
Dan Gohmanbdedd442008-08-20 00:11:48 +000027
Evan Cheng8b19e562008-09-03 06:44:39 +000028define double @bar(double* %p, double* %q) nounwind {
Dan Gohman8014e862008-08-20 00:23:20 +000029entry:
30 %r = load double* %p
31 %s = load double* %q
32 br label %fast
33
34fast:
Dan Gohmanae3a0be2009-06-04 22:49:04 +000035 %t0 = fadd double %r, %s
36 %t1 = fmul double %t0, %s
37 %t2 = fsub double %t1, %s
38 %t3 = fadd double %t2, 707.0
Dan Gohman8014e862008-08-20 00:23:20 +000039 br label %exit
40
41exit:
Dan Gohman10df0fa2008-08-27 01:09:54 +000042 ret double %t3
Dan Gohman8014e862008-08-20 00:23:20 +000043}
44
Evan Cheng8b19e562008-09-03 06:44:39 +000045define i32 @cast() nounwind {
Owen Anderson6d0c25e2008-08-25 20:20:32 +000046entry:
47 %tmp2 = bitcast i32 0 to i32
48 ret i32 %tmp2
49}
Dan Gohman474d3b32009-03-13 23:53:06 +000050
Dan Gohmand00d2fe2009-03-13 23:54:51 +000051define i1 @ptrtoint_i1(i8* %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000052 %t = ptrtoint i8* %p to i1
53 ret i1 %t
54}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000055define i8* @inttoptr_i1(i1 %p) nounwind {
Dan Gohman474d3b32009-03-13 23:53:06 +000056 %t = inttoptr i1 %p to i8*
57 ret i8* %t
58}
Dan Gohmand00d2fe2009-03-13 23:54:51 +000059define i32 @ptrtoint_i32(i8* %p) nounwind {
60 %t = ptrtoint i8* %p to i32
61 ret i32 %t
62}
63define i8* @inttoptr_i32(i32 %p) nounwind {
64 %t = inttoptr i32 %p to i8*
65 ret i8* %t
66}