Reapply bottom-up fast-isel, with several fixes for x86-32:
[oota-llvm.git] / test / CodeGen / X86 / fast-isel.ll
1 ; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86 -mattr=sse2
2 ; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86-64
3
4 ; This tests very minimal fast-isel functionality.
5
6 define i32* @foo(i32* %p, i32* %q, i32** %z) nounwind {
7 entry:
8   %r = load i32* %p
9   %s = load i32* %q
10   %y = load i32** %z
11   br label %fast
12
13 fast:
14   %t0 = add i32 %r, %s
15   %t1 = mul i32 %t0, %s
16   %t2 = sub i32 %t1, %s
17   %t3 = and i32 %t2, %s
18   %t4 = xor i32 %t3, 3
19   %t5 = xor i32 %t4, %s
20   %t6 = add i32 %t5, 2
21   %t7 = getelementptr i32* %y, i32 1
22   %t8 = getelementptr i32* %t7, i32 %t6
23   br label %exit
24
25 exit:
26   ret i32* %t8
27 }
28
29 define double @bar(double* %p, double* %q) nounwind {
30 entry:
31   %r = load double* %p
32   %s = load double* %q
33   br label %fast
34
35 fast:
36   %t0 = fadd double %r, %s
37   %t1 = fmul double %t0, %s
38   %t2 = fsub double %t1, %s
39   %t3 = fadd double %t2, 707.0
40   br label %exit
41
42 exit:
43   ret double %t3
44 }
45
46 define i32 @cast() nounwind {
47 entry:
48         %tmp2 = bitcast i32 0 to i32
49         ret i32 %tmp2
50 }
51
52 define void @ptrtoint_i1(i8* %p, i1* %q) nounwind {
53   %t = ptrtoint i8* %p to i1
54   store i1 %t, i1* %q
55   ret void
56 }
57 define i8* @inttoptr_i1(i1 %p) nounwind {
58   %t = inttoptr i1 %p to i8*
59   ret i8* %t
60 }
61 define i32 @ptrtoint_i32(i8* %p) nounwind {
62   %t = ptrtoint i8* %p to i32
63   ret i32 %t
64 }
65 define i8* @inttoptr_i32(i32 %p) nounwind {
66   %t = inttoptr i32 %p to i8*
67   ret i8* %t
68 }
69
70 define i8 @trunc_i32_i8(i32 %x) signext nounwind  {
71         %tmp1 = trunc i32 %x to i8
72         ret i8 %tmp1
73 }
74
75 define i8 @trunc_i16_i8(i16 signext %x) signext nounwind  {
76         %tmp1 = trunc i16 %x to i8
77         ret i8 %tmp1
78 }
79
80 define i8 @shl_i8(i8 %a, i8 %c) nounwind {
81        %tmp = shl i8 %a, %c
82        ret i8 %tmp
83 }
84
85 define i8 @mul_i8(i8 %a) nounwind {
86        %tmp = mul i8 %a, 17
87        ret i8 %tmp
88 }
89
90 define void @load_store_i1(i1* %p, i1* %q) nounwind {
91   %t = load i1* %p
92   store i1 %t, i1* %q
93   ret void
94 }