Covnert tests to not use indexed load/stores
[oota-llvm.git] / test / Feature / recursivetype.ll
1 ; This file contains the output from the following compiled C code:
2 ; typedef struct list {
3 ;   struct list *Next;
4 ;   int Data;
5 ; } list;
6 ;
7 ; // Iterative insert fn
8 ; void InsertIntoListTail(list **L, int Data) {
9 ;   while (*L)
10 ;     L = &(*L)->Next;
11 ;   *L = (list*)malloc(sizeof(list));
12 ;   (*L)->Data = Data;
13 ;   (*L)->Next = 0;
14 ; }
15 ;
16 ; // Recursive list search fn
17 ; list *FindData(list *L, int Data) {
18 ;   if (L == 0) return 0;
19 ;   if (L->Data == Data) return L;
20 ;   return FindData(L->Next, Data);
21 ; }
22 ;
23 ; void DoListStuff() {
24 ;   list *MyList = 0;
25 ;   InsertIntoListTail(&MyList, 100);
26 ;   InsertIntoListTail(&MyList, 12);
27 ;   InsertIntoListTail(&MyList, 42);
28 ;   InsertIntoListTail(&MyList, 1123);
29 ;   InsertIntoListTail(&MyList, 1213);
30 ;
31 ;   if (FindData(MyList, 75)) foundIt();
32 ;   if (FindData(MyList, 42)) foundIt();
33 ;   if (FindData(MyList, 700)) foundIt();
34 ; }
35
36 %list = type { %list*, int }
37
38 declare sbyte *"malloc"(uint)
39
40 ;;**********************
41 implementation
42 ;;**********************
43
44 void "InsertIntoListTail"(%list** %L, int %Data)
45 begin
46 bb1:
47         %reg116 = load %list** %L                               ;;<%list*>
48         %cast1004 = cast ulong 0 to %list*                      ;;<%list*>
49         %cond1000 = seteq %list* %reg116, %cast1004             ;;<bool>
50         br bool %cond1000, label %bb3, label %bb2
51
52 bb2:
53         %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ]   ;;<%list**>
54         %cast1010 = cast %list** %reg117 to %list***            ;;<%list***>
55         %reg118 = load %list*** %cast1010                       ;;<%list**>
56         %reg109 = load %list** %reg118                          ;;<%list*>
57         %cast1005 = cast ulong 0 to %list*                      ;;<%list*>
58         %cond1001 = setne %list* %reg109, %cast1005             ;;<bool>
59         br bool %cond1001, label %bb2, label %bb3
60
61 bb3:
62         %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ]   ;;<%list**>
63         %cast1006 = cast %list** %reg119 to sbyte**             ;;<sbyte**>
64         %reg111 = call sbyte* %malloc(uint 16)                  ;;<sbyte*>
65         store sbyte* %reg111, sbyte** %cast1006                 ;;<void>
66         %cast1007 = cast ulong 8 to sbyte*                      ;;<sbyte*>
67         %reg1002 = add sbyte* %reg111, %cast1007                ;;<sbyte*>
68         %cast1008 = cast sbyte* %reg1002 to int*                ;;<int*>
69         store int %Data, int* %cast1008                         ;;<void>
70         %cast1003 = cast ulong 0 to ulong*                      ;;<ulong*>
71         %cast1009 = cast sbyte* %reg111 to ulong**              ;;<ulong**>
72         store ulong* %cast1003, ulong** %cast1009               ;;<void>
73         ret void
74 end
75
76 %list* "FindData"(%list* %L, int %Data)
77 begin
78 bb1:
79         br label %bb2
80
81 bb2:
82         %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ]    ;;<%list*>
83         %cast1014 = cast ulong 0 to %list*                      ;;<%list*>
84         %cond1011 = setne %list* %reg115, %cast1014             ;;<bool>
85         br bool %cond1011, label %bb4, label %bb3
86
87 bb3:
88         ret %list* null
89
90 bb4:
91         %idx = getelementptr %list* %reg115, uint 0, ubyte 1                  ;;<int>
92         %reg111 = load int* %idx
93         %cond1013 = setne int %reg111, %Data                    ;;<bool>
94         br bool %cond1013, label %bb6, label %bb5
95
96 bb5:
97         ret %list* %reg115
98
99 bb6:
100         %idx2 = getelementptr %list* %reg115, uint 0, ubyte 0                  ;;<%list*>
101         %reg116 = load %list** %idx2
102         br label %bb2
103 end