Merging r261039:
[oota-llvm.git] / test / CodeGen / X86 / 2009-04-29-LinearScanBug.ll
1 ; RUN: llc < %s -mtriple=i386-apple-darwin10
2 ; rdar://6837009
3
4         %0 = type { %struct.pf_state*, %struct.pf_state*, %struct.pf_state*, i32 }
5         %1 = type { %2 }
6         %2 = type { %struct.pf_addr, %struct.pf_addr }
7         %3 = type { %struct.in6_addr }
8         %4 = type { [4 x i32] }
9         %5 = type { %struct.pfi_dynaddr*, [4 x i8] }
10         %6 = type { %struct.pfi_dynaddr*, %struct.pfi_dynaddr** }
11         %7 = type { %struct.pfr_ktable*, %struct.pfr_ktable*, %struct.pfr_ktable*, i32 }
12         %8 = type { %struct.pfr_ktable* }
13         %9 = type { i8* }
14         %10 = type { %11 }
15         %11 = type { i8*, i8*, %struct.radix_node* }
16         %12 = type { [2 x %struct.pf_rulequeue], %13, %13 }
17         %13 = type { %struct.pf_rulequeue*, %struct.pf_rule**, i32, i32, i32 }
18         %14 = type { %struct.pf_anchor*, %struct.pf_anchor*, %struct.pf_anchor*, i32 }
19         %15 = type { %struct.pfi_kif*, %struct.pfi_kif*, %struct.pfi_kif*, i32 }
20         %16 = type { %struct.ifnet*, %struct.ifnet** }
21         %17 = type { %18 }
22         %18 = type { %struct.pkthdr, %19 }
23         %19 = type { %struct.m_ext, [176 x i8] }
24         %20 = type { %struct.ifmultiaddr*, %struct.ifmultiaddr** }
25         %21 = type { i32, %22 }
26         %22 = type { i8*, [4 x i8] }
27         %23 = type { %struct.tcphdr* }
28         %24 = type { %struct.pf_ike_state }
29         %25 = type { %struct.pf_state_key*, %struct.pf_state_key*, %struct.pf_state_key*, i32 }
30         %26 = type { %struct.pf_src_node*, %struct.pf_src_node*, %struct.pf_src_node*, i32 }
31         %struct.anon = type { %struct.pf_state*, %struct.pf_state** }
32         %struct.au_mask_t = type { i32, i32 }
33         %struct.bpf_if = type opaque
34         %struct.dlil_threading_info = type opaque
35         %struct.ether_header = type { [6 x i8], [6 x i8], i16 }
36         %struct.ext_refsq = type { %struct.ext_refsq*, %struct.ext_refsq* }
37         %struct.hook_desc = type { %struct.hook_desc_head, void (i8*)*, i8* }
38         %struct.hook_desc_head = type { %struct.hook_desc*, %struct.hook_desc** }
39         %struct.if_data_internal = type { i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i32, i32, %struct.au_mask_t, i32, i32, i32 }
40         %struct.ifaddr = type { %struct.sockaddr*, %struct.sockaddr*, %struct.sockaddr*, %struct.ifnet*, %struct.ifaddrhead, void (i32, %struct.rtentry*, %struct.sockaddr*)*, i32, i32, i32, void (%struct.ifaddr*)*, void (%struct.ifaddr*, i32)*, i32 }
41         %struct.ifaddrhead = type { %struct.ifaddr*, %struct.ifaddr** }
42         %struct.ifmultiaddr = type { %20, %struct.sockaddr*, %struct.ifmultiaddr*, %struct.ifnet*, i32, i8*, i32, void (i8*)* }
43         %struct.ifmultihead = type { %struct.ifmultiaddr* }
44         %struct.ifnet = type { i8*, i8*, %16, %struct.ifaddrhead, i32, i32 (%struct.ifnet*, %struct.sockaddr*)*, i32, %struct.bpf_if*, i16, i16, i16, i16, i32, i8*, i32, %struct.if_data_internal, i32, i32 (%struct.ifnet*, %struct.mbuf*)*, i32 (%struct.ifnet*, i32, i8*)*, i32 (%struct.ifnet*, i32, i32 (%struct.ifnet*, %struct.mbuf*)*)*, void (%struct.ifnet*)*, i32 (%struct.ifnet*, %struct.mbuf*, i8*, i32*)*, void (%struct.ifnet*, %struct.kev_msg*)*, i32 (%struct.ifnet*, %struct.mbuf**, %struct.sockaddr*, i8*, i8*)*, i32, %struct.ifnet_filter_head, i32, i8*, i32, %struct.ifmultihead, i32, i32 (%struct.ifnet*, i32, %struct.ifnet_demux_desc*, i32)*, i32 (%struct.ifnet*, i32)*, %struct.proto_hash_entry*, i8*, %struct.dlil_threading_info*, i8*, %struct.ifqueue, [1 x i32], i32, %struct.ifprefixhead, %struct.lck_rw_t*, %21, i32, %struct.thread*, %struct.pfi_kif*, %struct.lck_mtx_t*, %struct.route }
45         %struct.ifnet_demux_desc = type { i32, i8*, i32 }
46         %struct.ifnet_filter = type opaque
47         %struct.ifnet_filter_head = type { %struct.ifnet_filter*, %struct.ifnet_filter** }
48         %struct.ifprefix = type { %struct.sockaddr*, %struct.ifnet*, %struct.ifprefixhead, i8, i8 }
49         %struct.ifprefixhead = type { %struct.ifprefix*, %struct.ifprefix** }
50         %struct.ifqueue = type { i8*, i8*, i32, i32, i32 }
51         %struct.in6_addr = type { %4 }
52         %struct.in_addr = type { i32 }
53         %struct.kev_d_vectors = type { i32, i8* }
54         %struct.kev_msg = type { i32, i32, i32, i32, [5 x %struct.kev_d_vectors] }
55         %struct.lck_mtx_t = type { [3 x i32] }
56         %struct.lck_rw_t = type <{ [3 x i32] }>
57         %struct.m_ext = type { i8*, void (i8*, i32, i8*)*, i32, i8*, %struct.ext_refsq, %struct.au_mask_t* }
58         %struct.m_hdr = type { %struct.mbuf*, %struct.mbuf*, i32, i8*, i16, i16 }
59         %struct.m_tag = type { %struct.packet_tags, i16, i16, i32 }
60         %struct.mbuf = type { %struct.m_hdr, %17 }
61         %struct.packet_tags = type { %struct.m_tag* }
62         %struct.pf_addr = type { %3 }
63         %struct.pf_addr_wrap = type <{ %1, %5, i8, i8, [6 x i8] }>
64         %struct.pf_anchor = type { %14, %14, %struct.pf_anchor*, %struct.pf_anchor_node, [64 x i8], [1024 x i8], %struct.pf_ruleset, i32, i32 }
65         %struct.pf_anchor_node = type { %struct.pf_anchor* }
66         %struct.pf_app_state = type { void (%struct.pf_state*, i32, i32, %struct.pf_pdesc*, %struct.pfi_kif*)*, i32 (%struct.pf_app_state*, %struct.pf_app_state*)*, i32 (%struct.pf_app_state*, %struct.pf_app_state*)*, %24 }
67         %struct.pf_ike_state = type { i64 }
68         %struct.pf_mtag = type { i8*, i32, i32, i16, i8, i8 }
69         %struct.pf_palist = type { %struct.pf_pooladdr*, %struct.pf_pooladdr** }
70         %struct.pf_pdesc = type { %struct.pf_threshold, i64, %23, %struct.pf_addr, %struct.pf_addr, %struct.pf_rule*, %struct.pf_addr*, %struct.pf_addr*, %struct.ether_header*, %struct.mbuf*, i32, %struct.pf_mtag*, i16*, i32, i16, i8, i8, i8, i8 }
71         %struct.pf_pool = type { %struct.pf_palist, [2 x i32], %struct.pf_pooladdr*, [4 x i8], %struct.in6_addr, %struct.pf_addr, i32, [2 x i16], i8, i8, [1 x i32] }
72         %struct.pf_pooladdr = type <{ %struct.pf_addr_wrap, %struct.pf_palist, [2 x i32], [16 x i8], %struct.pfi_kif*, [1 x i32] }>
73         %struct.pf_rule = type <{ %struct.pf_rule_addr, %struct.pf_rule_addr, [8 x %struct.pf_rule_ptr], [64 x i8], [16 x i8], [64 x i8], [64 x i8], [64 x i8], [64 x i8], [32 x i8], %struct.pf_rulequeue, [2 x i32], %struct.pf_pool, i64, [2 x i64], [2 x i64], %struct.pfi_kif*, [4 x i8], %struct.pf_anchor*, [4 x i8], %struct.pfr_ktable*, [4 x i8], i32, i32, [26 x i32], i32, i32, i32, i32, i32, i32, %struct.au_mask_t, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, [2 x i8], %struct.pf_rule_gid, %struct.pf_rule_gid, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, [2 x i8] }>
74         %struct.pf_rule_addr = type <{ %struct.pf_addr_wrap, %struct.pf_rule_xport, i8, [7 x i8] }>
75         %struct.pf_rule_gid = type { [2 x i32], i8, [3 x i8] }
76         %struct.pf_rule_ptr = type { %struct.pf_rule*, [4 x i8] }
77         %struct.pf_rule_xport = type { i32, [4 x i8] }
78         %struct.pf_rulequeue = type { %struct.pf_rule*, %struct.pf_rule** }
79         %struct.pf_ruleset = type { [5 x %12], %struct.pf_anchor*, i32, i32, i32 }
80         %struct.pf_src_node = type <{ %26, %struct.pf_addr, %struct.pf_addr, %struct.pf_rule_ptr, %struct.pfi_kif*, [2 x i64], [2 x i64], i32, i32, %struct.pf_threshold, i64, i64, i8, i8, [2 x i8] }>
81         %struct.pf_state = type <{ i64, i32, i32, %struct.anon, %struct.anon, %0, %struct.pf_state_peer, %struct.pf_state_peer, %struct.pf_rule_ptr, %struct.pf_rule_ptr, %struct.pf_rule_ptr, %struct.pf_addr, %struct.hook_desc_head, %struct.pf_state_key*, %struct.pfi_kif*, %struct.pfi_kif*, %struct.pf_src_node*, %struct.pf_src_node*, [2 x i64], [2 x i64], i64, i64, i64, i16, i8, i8, i8, i8, [6 x i8] }>
82         %struct.pf_state_host = type { %struct.pf_addr, %struct.in_addr }
83         %struct.pf_state_key = type { %struct.pf_state_host, %struct.pf_state_host, %struct.pf_state_host, i8, i8, i8, i8, %struct.pf_app_state*, %25, %25, %struct.anon, i16 }
84         %struct.pf_state_peer = type { i32, i32, i32, i16, i8, i8, i16, i8, %struct.pf_state_scrub*, [3 x i8] }
85         %struct.pf_state_scrub = type { %struct.au_mask_t, i32, i32, i32, i16, i8, i8, i32 }
86         %struct.pf_threshold = type { i32, i32, i32, i32 }
87         %struct.pfi_dynaddr = type { %6, %struct.pf_addr, %struct.pf_addr, %struct.pf_addr, %struct.pf_addr, %struct.pfr_ktable*, %struct.pfi_kif*, i8*, i32, i32, i32, i8, i8 }
88         %struct.pfi_kif = type { [16 x i8], %15, [2 x [2 x [2 x i64]]], [2 x [2 x [2 x i64]]], i64, i32, i8*, %struct.ifnet*, i32, i32, %6 }
89         %struct.pfr_ktable = type { %struct.pfr_tstats, %7, %8, %struct.radix_node_head*, %struct.radix_node_head*, %struct.pfr_ktable*, %struct.pfr_ktable*, %struct.pf_ruleset*, i64, i32 }
90         %struct.pfr_table = type { [1024 x i8], [32 x i8], i32, i8 }
91         %struct.pfr_tstats = type { %struct.pfr_table, [2 x [3 x i64]], [2 x [3 x i64]], i64, i64, i64, i32, [2 x i32] }
92         %struct.pkthdr = type { i32, %struct.ifnet*, i8*, i32, i32, i32, i16, i16, %struct.packet_tags }
93         %struct.proto_hash_entry = type opaque
94         %struct.radix_mask = type { i16, i8, i8, %struct.radix_mask*, %9, i32 }
95         %struct.radix_node = type { %struct.radix_mask*, %struct.radix_node*, i16, i8, i8, %10 }
96         %struct.radix_node_head = type { %struct.radix_node*, i32, i32, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*, %struct.radix_node*)*, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*, %struct.radix_node*)*, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*)*, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*)*, %struct.radix_node* (i8*, %struct.radix_node_head*)*, %struct.radix_node* (i8*, %struct.radix_node_head*, i32 (%struct.radix_node*, i8*)*, i8*)*, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*)*, %struct.radix_node* (i8*, i8*, %struct.radix_node_head*, i32 (%struct.radix_node*, i8*)*, i8*)*, %struct.radix_node* (i8*, %struct.radix_node_head*)*, i32 (%struct.radix_node_head*, i32 (%struct.radix_node*, i8*)*, i8*)*, i32 (%struct.radix_node_head*, i8*, i8*, i32 (%struct.radix_node*, i8*)*, i8*)*, void (%struct.radix_node*, %struct.radix_node_head*)*, [3 x %struct.radix_node], i32 }
97         %struct.route = type { %struct.rtentry*, i32, %struct.sockaddr }
98         %struct.rt_metrics = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32] }
99         %struct.rtentry = type { [2 x %struct.radix_node], %struct.sockaddr*, i32, i32, %struct.ifnet*, %struct.ifaddr*, %struct.sockaddr*, i8*, void (i8*)*, %struct.rt_metrics, %struct.rtentry*, %struct.rtentry*, i32, %struct.lck_mtx_t }
100         %struct.sockaddr = type { i8, i8, [14 x i8] }
101         %struct.tcphdr = type { i16, i16, i32, i32, i8, i8, i16, i16, i16 }
102         %struct.thread = type opaque
103 @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.pf_state_key*, %struct.pf_state_key*)* @pf_state_compare_ext_gwy to i8*)], section "llvm.metadata"           ; <[1 x i8*]*> [#uses=0]
104
105 define fastcc i32 @pf_state_compare_ext_gwy(%struct.pf_state_key* nocapture %a, %struct.pf_state_key* nocapture %b) nounwind optsize ssp {
106 entry:
107         %0 = zext i8 0 to i32           ; <i32> [#uses=2]
108         %1 = load i8, i8* null, align 1         ; <i8> [#uses=2]
109         %2 = zext i8 %1 to i32          ; <i32> [#uses=1]
110         %3 = sub i32 %0, %2             ; <i32> [#uses=1]
111         %4 = icmp eq i8 0, %1           ; <i1> [#uses=1]
112         br i1 %4, label %bb1, label %bb79
113
114 bb1:            ; preds = %entry
115         %5 = load i8, i8* null, align 4         ; <i8> [#uses=2]
116         %6 = zext i8 %5 to i32          ; <i32> [#uses=2]
117         %7 = getelementptr %struct.pf_state_key, %struct.pf_state_key* %b, i32 0, i32 3         ; <i8*> [#uses=1]
118         %8 = load i8, i8* %7, align 4           ; <i8> [#uses=2]
119         %9 = zext i8 %8 to i32          ; <i32> [#uses=1]
120         %10 = sub i32 %6, %9            ; <i32> [#uses=1]
121         %11 = icmp eq i8 %5, %8         ; <i1> [#uses=1]
122         br i1 %11, label %bb3, label %bb79
123
124 bb3:            ; preds = %bb1
125         switch i32 %0, label %bb23 [
126                 i32 1, label %bb4
127                 i32 6, label %bb6
128                 i32 17, label %bb10
129                 i32 47, label %bb17
130                 i32 50, label %bb21
131                 i32 58, label %bb4
132         ]
133
134 bb4:            ; preds = %bb3, %bb3
135         %12 = load i16, i16* null, align 4              ; <i16> [#uses=1]
136         %13 = zext i16 %12 to i32               ; <i32> [#uses=1]
137         %14 = sub i32 0, %13            ; <i32> [#uses=1]
138         br i1 false, label %bb23, label %bb79
139
140 bb6:            ; preds = %bb3
141         %15 = load i16, i16* null, align 4              ; <i16> [#uses=1]
142         %16 = zext i16 %15 to i32               ; <i32> [#uses=1]
143         %17 = sub i32 0, %16            ; <i32> [#uses=1]
144         ret i32 %17
145
146 bb10:           ; preds = %bb3
147         %18 = load i8, i8* null, align 1                ; <i8> [#uses=2]
148         %19 = zext i8 %18 to i32                ; <i32> [#uses=1]
149         %20 = sub i32 0, %19            ; <i32> [#uses=1]
150         %21 = icmp eq i8 0, %18         ; <i1> [#uses=1]
151         br i1 %21, label %bb12, label %bb79
152
153 bb12:           ; preds = %bb10
154         %22 = load i16, i16* null, align 4              ; <i16> [#uses=1]
155         %23 = zext i16 %22 to i32               ; <i32> [#uses=1]
156         %24 = sub i32 0, %23            ; <i32> [#uses=1]
157         ret i32 %24
158
159 bb17:           ; preds = %bb3
160         %25 = load i8, i8* null, align 1                ; <i8> [#uses=2]
161         %26 = icmp eq i8 %25, 1         ; <i1> [#uses=1]
162         br i1 %26, label %bb18, label %bb23
163
164 bb18:           ; preds = %bb17
165         %27 = icmp eq i8 %25, 0         ; <i1> [#uses=1]
166         br i1 %27, label %bb19, label %bb23
167
168 bb19:           ; preds = %bb18
169         %28 = load i16, i16* null, align 4              ; <i16> [#uses=1]
170         %29 = zext i16 %28 to i32               ; <i32> [#uses=1]
171         %30 = sub i32 0, %29            ; <i32> [#uses=1]
172         br i1 false, label %bb23, label %bb79
173
174 bb21:           ; preds = %bb3
175         %31 = getelementptr %struct.pf_state_key, %struct.pf_state_key* %a, i32 0, i32 1, i32 1, i32 0          ; <i32*> [#uses=1]
176         %32 = load i32, i32* %31, align 4               ; <i32> [#uses=2]
177         %33 = getelementptr %struct.pf_state_key, %struct.pf_state_key* %b, i32 0, i32 1, i32 1, i32 0          ; <i32*> [#uses=1]
178         %34 = load i32, i32* %33, align 4               ; <i32> [#uses=2]
179         %35 = sub i32 %32, %34          ; <i32> [#uses=1]
180         %36 = icmp eq i32 %32, %34              ; <i1> [#uses=1]
181         br i1 %36, label %bb23, label %bb79
182
183 bb23:           ; preds = %bb21, %bb19, %bb18, %bb17, %bb4, %bb3
184         %cond = icmp eq i32 %6, 2               ; <i1> [#uses=1]
185         br i1 %cond, label %bb24, label %bb70
186
187 bb24:           ; preds = %bb23
188         ret i32 1
189
190 bb70:           ; preds = %bb23
191         %37 = load i32 (%struct.pf_app_state*, %struct.pf_app_state*)*, i32 (%struct.pf_app_state*, %struct.pf_app_state*)** null, align 4              ; <i32 (%struct.pf_app_state*, %struct.pf_app_state*)*> [#uses=3]
192         br i1 false, label %bb78, label %bb73
193
194 bb73:           ; preds = %bb70
195         %38 = load i32 (%struct.pf_app_state*, %struct.pf_app_state*)*, i32 (%struct.pf_app_state*, %struct.pf_app_state*)** null, align 4              ; <i32 (%struct.pf_app_state*, %struct.pf_app_state*)*> [#uses=2]
196         %39 = icmp eq i32 (%struct.pf_app_state*, %struct.pf_app_state*)* %38, null             ; <i1> [#uses=1]
197         br i1 %39, label %bb78, label %bb74
198
199 bb74:           ; preds = %bb73
200         %40 = ptrtoint i32 (%struct.pf_app_state*, %struct.pf_app_state*)* %37 to i32           ; <i32> [#uses=1]
201         %41 = sub i32 0, %40            ; <i32> [#uses=1]
202         %42 = icmp eq i32 (%struct.pf_app_state*, %struct.pf_app_state*)* %38, %37              ; <i1> [#uses=1]
203         br i1 %42, label %bb76, label %bb79
204
205 bb76:           ; preds = %bb74
206         %43 = tail call i32 %37(%struct.pf_app_state* null, %struct.pf_app_state* null) nounwind                ; <i32> [#uses=1]
207         ret i32 %43
208
209 bb78:           ; preds = %bb73, %bb70
210         ret i32 0
211
212 bb79:           ; preds = %bb74, %bb21, %bb19, %bb10, %bb4, %bb1, %entry
213         %.0 = phi i32 [ %3, %entry ], [ %10, %bb1 ], [ %14, %bb4 ], [ %20, %bb10 ], [ %30, %bb19 ], [ %35, %bb21 ], [ %41, %bb74 ]              ; <i32> [#uses=1]
214         ret i32 %.0
215 }