Add a priority queue class, which is a wrapper around std::priority_queue
[oota-llvm.git] / test / Transforms / InstCombine / 2006-12-10-ICmp-GEP-GEP.ll
1 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
2 ; RUN:    grep -v {icmp ult i32}
3 ; END.
4
5 target datalayout = "e-p:32:32"
6 target triple = "i686-pc-linux-gnu"
7         %struct.edgeBox = type { i16, i16, i16, i16, i16, i16 }
8 @qsz = external global i32              ; <i32*> [#uses=12]
9 @thresh = external global i32           ; <i32*> [#uses=2]
10 @mthresh = external global i32          ; <i32*> [#uses=1]
11
12 define i32 @qsorte(i8* %base, i32 %n, i32 %size) {
13 entry:
14         %tmp = icmp sgt i32 %n, 1               ; <i1> [#uses=1]
15         br i1 %tmp, label %cond_next, label %return
16
17 cond_next:              ; preds = %entry
18         store i32 %size, i32* @qsz
19         %tmp3 = shl i32 %size, 2                ; <i32> [#uses=1]
20         store i32 %tmp3, i32* @thresh
21         %tmp4 = load i32* @qsz          ; <i32> [#uses=1]
22         %tmp5 = mul i32 %tmp4, 6                ; <i32> [#uses=1]
23         store i32 %tmp5, i32* @mthresh
24         %tmp6 = load i32* @qsz          ; <i32> [#uses=1]
25         %tmp8 = mul i32 %tmp6, %n               ; <i32> [#uses=1]
26         %tmp9 = getelementptr i8* %base, i32 %tmp8              ; <i8*> [#uses=3]
27         %tmp11 = icmp sgt i32 %n, 3             ; <i1> [#uses=1]
28         br i1 %tmp11, label %cond_true12, label %bb30
29
30 cond_true12:            ; preds = %cond_next
31         %tmp156 = call i32 @qste( i8* %base, i8* %tmp9 )                ; <i32> [#uses=0]
32         %tmp16 = load i32* @thresh              ; <i32> [#uses=1]
33         %tmp18 = getelementptr i8* %base, i32 %tmp16            ; <i8*> [#uses=2]
34         %tmp3117 = load i32* @qsz               ; <i32> [#uses=1]
35         %tmp3318 = getelementptr i8* %base, i32 %tmp3117                ; <i8*> [#uses=2]
36         %tmp3621 = icmp ult i8* %tmp3318, %tmp18                ; <i1> [#uses=1]
37         br i1 %tmp3621, label %bb, label %bb37
38
39 bb:             ; preds = %bb30, %cond_true12
40         %hi.0.0 = phi i8* [ %tmp18, %cond_true12 ], [ %hi.0, %bb30 ]            ; <i8*> [#uses=4]
41         %j.1.0 = phi i8* [ %base, %cond_true12 ], [ %j.1, %bb30 ]               ; <i8*> [#uses=4]
42         %tmp33.0 = phi i8* [ %tmp3318, %cond_true12 ], [ %tmp33, %bb30 ]                ; <i8*> [#uses=6]
43         %tmp3.upgrd.1 = bitcast i8* %j.1.0 to %struct.edgeBox*          ; <%struct.edgeBox*> [#uses=1]
44         %tmp4.upgrd.2 = bitcast i8* %tmp33.0 to %struct.edgeBox*                ; <%struct.edgeBox*> [#uses=1]
45         %tmp255 = call i32 @comparee( %struct.edgeBox* %tmp3.upgrd.1, %struct.edgeBox* %tmp4.upgrd.2 )          ; <i32> [#uses=1]
46         %tmp26 = icmp sgt i32 %tmp255, 0                ; <i1> [#uses=1]
47         br i1 %tmp26, label %cond_true27, label %bb30
48
49 cond_true27:            ; preds = %bb
50         br label %bb30
51
52 bb30:           ; preds = %cond_true27, %bb, %cond_next
53         %hi.0.3 = phi i8* [ %hi.0.0, %cond_true27 ], [ %hi.0.0, %bb ], [ undef, %cond_next ]            ; <i8*> [#uses=0]
54         %j.1.3 = phi i8* [ %j.1.0, %cond_true27 ], [ %j.1.0, %bb ], [ undef, %cond_next ]               ; <i8*> [#uses=0]
55         %tmp33.3 = phi i8* [ %tmp33.0, %cond_true27 ], [ %tmp33.0, %bb ], [ undef, %cond_next ]         ; <i8*> [#uses=0]
56         %hi.0 = phi i8* [ %tmp9, %cond_next ], [ %hi.0.0, %bb ], [ %hi.0.0, %cond_true27 ]              ; <i8*> [#uses=2]
57         %lo.1 = phi i8* [ %tmp33.0, %cond_true27 ], [ %tmp33.0, %bb ], [ %base, %cond_next ]            ; <i8*> [#uses=1]
58         %j.1 = phi i8* [ %tmp33.0, %cond_true27 ], [ %j.1.0, %bb ], [ %base, %cond_next ]               ; <i8*> [#uses=2]
59         %tmp31 = load i32* @qsz         ; <i32> [#uses=1]
60         %tmp33 = getelementptr i8* %lo.1, i32 %tmp31            ; <i8*> [#uses=2]
61         %tmp36 = icmp ult i8* %tmp33, %hi.0             ; <i1> [#uses=1]
62         br i1 %tmp36, label %bb, label %bb37
63
64 bb37:           ; preds = %bb30, %cond_true12
65         %j.1.1 = phi i8* [ %j.1, %bb30 ], [ %base, %cond_true12 ]               ; <i8*> [#uses=4]
66         %tmp40 = icmp eq i8* %j.1.1, %base              ; <i1> [#uses=1]
67         br i1 %tmp40, label %bb115, label %cond_true41
68
69 cond_true41:            ; preds = %bb37
70         %tmp43 = load i32* @qsz         ; <i32> [#uses=1]
71         %tmp45 = getelementptr i8* %base, i32 %tmp43            ; <i8*> [#uses=2]
72         %tmp6030 = icmp ult i8* %base, %tmp45           ; <i1> [#uses=1]
73         br i1 %tmp6030, label %bb46, label %bb115
74
75 bb46:           ; preds = %bb46, %cond_true41
76         %j.2.0 = phi i8* [ %j.1.1, %cond_true41 ], [ %tmp52, %bb46 ]            ; <i8*> [#uses=3]
77         %i.2.0 = phi i8* [ %base, %cond_true41 ], [ %tmp56, %bb46 ]             ; <i8*> [#uses=3]
78         %tmp.upgrd.3 = load i8* %j.2.0          ; <i8> [#uses=2]
79         %tmp49 = load i8* %i.2.0                ; <i8> [#uses=1]
80         store i8 %tmp49, i8* %j.2.0
81         %tmp52 = getelementptr i8* %j.2.0, i32 1                ; <i8*> [#uses=2]
82         store i8 %tmp.upgrd.3, i8* %i.2.0
83         %tmp56 = getelementptr i8* %i.2.0, i32 1                ; <i8*> [#uses=3]
84         %tmp60 = icmp ult i8* %tmp56, %tmp45            ; <i1> [#uses=1]
85         br i1 %tmp60, label %bb46, label %bb115
86
87 bb66:           ; preds = %bb115, %bb66
88         %hi.3 = phi i8* [ %tmp118, %bb115 ], [ %tmp70, %bb66 ]          ; <i8*> [#uses=2]
89         %tmp67 = load i32* @qsz         ; <i32> [#uses=2]
90         %tmp68 = sub i32 0, %tmp67              ; <i32> [#uses=1]
91         %tmp70 = getelementptr i8* %hi.3, i32 %tmp68            ; <i8*> [#uses=2]
92         %tmp.upgrd.4 = bitcast i8* %tmp70 to %struct.edgeBox*           ; <%struct.edgeBox*> [#uses=1]
93         %tmp1 = bitcast i8* %tmp118 to %struct.edgeBox*         ; <%struct.edgeBox*> [#uses=1]
94         %tmp732 = call i32 @comparee( %struct.edgeBox* %tmp.upgrd.4, %struct.edgeBox* %tmp1 )           ; <i32> [#uses=1]
95         %tmp74 = icmp sgt i32 %tmp732, 0                ; <i1> [#uses=1]
96         br i1 %tmp74, label %bb66, label %bb75
97
98 bb75:           ; preds = %bb66
99         %tmp76 = load i32* @qsz         ; <i32> [#uses=1]
100         %tmp70.sum = sub i32 %tmp76, %tmp67             ; <i32> [#uses=1]
101         %tmp78 = getelementptr i8* %hi.3, i32 %tmp70.sum                ; <i8*> [#uses=3]
102         %tmp81 = icmp eq i8* %tmp78, %tmp118            ; <i1> [#uses=1]
103         br i1 %tmp81, label %bb115, label %cond_true82
104
105 cond_true82:            ; preds = %bb75
106         %tmp83 = load i32* @qsz         ; <i32> [#uses=1]
107         %tmp118.sum = add i32 %tmp116, %tmp83           ; <i32> [#uses=1]
108         %tmp85 = getelementptr i8* %min.1, i32 %tmp118.sum              ; <i8*> [#uses=1]
109         %tmp10937 = getelementptr i8* %tmp85, i32 -1            ; <i8*> [#uses=3]
110         %tmp11239 = icmp ult i8* %tmp10937, %tmp118             ; <i1> [#uses=1]
111         br i1 %tmp11239, label %bb115, label %bb86
112
113 bb86:           ; preds = %bb104, %cond_true82
114         %tmp109.0 = phi i8* [ %tmp10937, %cond_true82 ], [ %tmp109, %bb104 ]            ; <i8*> [#uses=5]
115         %i.5.2 = phi i8* [ %i.5.3, %cond_true82 ], [ %i.5.1, %bb104 ]           ; <i8*> [#uses=0]
116         %tmp100.2 = phi i8* [ %tmp100.3, %cond_true82 ], [ %tmp100.1, %bb104 ]          ; <i8*> [#uses=0]
117         %tmp88 = load i8* %tmp109.0             ; <i8> [#uses=2]
118         %tmp9746 = load i32* @qsz               ; <i32> [#uses=1]
119         %tmp9847 = sub i32 0, %tmp9746          ; <i32> [#uses=1]
120         %tmp10048 = getelementptr i8* %tmp109.0, i32 %tmp9847           ; <i8*> [#uses=3]
121         %tmp10350 = icmp ult i8* %tmp10048, %tmp78              ; <i1> [#uses=1]
122         br i1 %tmp10350, label %bb104, label %bb91
123
124 bb91:           ; preds = %bb91, %bb86
125         %i.5.0 = phi i8* [ %tmp109.0, %bb86 ], [ %tmp100.0, %bb91 ]             ; <i8*> [#uses=1]
126         %tmp100.0 = phi i8* [ %tmp10048, %bb86 ], [ %tmp100, %bb91 ]            ; <i8*> [#uses=4]
127         %tmp93 = load i8* %tmp100.0             ; <i8> [#uses=1]
128         store i8 %tmp93, i8* %i.5.0
129         %tmp97 = load i32* @qsz         ; <i32> [#uses=1]
130         %tmp98 = sub i32 0, %tmp97              ; <i32> [#uses=1]
131         %tmp100 = getelementptr i8* %tmp100.0, i32 %tmp98               ; <i8*> [#uses=3]
132         %tmp103 = icmp ult i8* %tmp100, %tmp78          ; <i1> [#uses=1]
133         br i1 %tmp103, label %bb104, label %bb91
134
135 bb104:          ; preds = %bb91, %bb86
136         %i.5.1 = phi i8* [ %tmp109.0, %bb86 ], [ %tmp100.0, %bb91 ]             ; <i8*> [#uses=4]
137         %tmp100.1 = phi i8* [ %tmp10048, %bb86 ], [ %tmp100, %bb91 ]            ; <i8*> [#uses=3]
138         store i8 %tmp88, i8* %i.5.1
139         %tmp109 = getelementptr i8* %tmp109.0, i32 -1           ; <i8*> [#uses=3]
140         %tmp112 = icmp ult i8* %tmp109, %tmp118         ; <i1> [#uses=1]
141         br i1 %tmp112, label %bb115, label %bb86
142
143 bb115:          ; preds = %bb104, %cond_true82, %bb75, %bb46, %cond_true41, %bb37
144         %tmp109.1 = phi i8* [ undef, %bb37 ], [ %tmp109.1, %bb75 ], [ %tmp10937, %cond_true82 ], [ %tmp109, %bb104 ], [ undef, %bb46 ], [ undef, %cond_true41 ]         ; <i8*> [#uses=1]
145         %i.5.3 = phi i8* [ undef, %bb37 ], [ %i.5.3, %bb75 ], [ %i.5.3, %cond_true82 ], [ %i.5.1, %bb104 ], [ undef, %bb46 ], [ undef, %cond_true41 ]           ; <i8*> [#uses=3]
146         %tmp100.3 = phi i8* [ undef, %bb37 ], [ %tmp100.3, %bb75 ], [ %tmp100.3, %cond_true82 ], [ %tmp100.1, %bb104 ], [ undef, %bb46 ], [ undef, %cond_true41 ]               ; <i8*> [#uses=3]
147         %min.1 = phi i8* [ %tmp118, %bb104 ], [ %tmp118, %bb75 ], [ %base, %bb37 ], [ %base, %bb46 ], [ %base, %cond_true41 ], [ %tmp118, %cond_true82 ]                ; <i8*> [#uses=2]
148         %j.5 = phi i8* [ %tmp100.1, %bb104 ], [ %j.5, %bb75 ], [ %tmp52, %bb46 ], [ %j.1.1, %bb37 ], [ %j.1.1, %cond_true41 ], [ %j.5, %cond_true82 ]           ; <i8*> [#uses=2]
149         %i.4 = phi i8* [ %i.5.1, %bb104 ], [ %i.4, %bb75 ], [ %tmp56, %bb46 ], [ undef, %bb37 ], [ %base, %cond_true41 ], [ %i.4, %cond_true82 ]                ; <i8*> [#uses=2]
150         %c.4 = phi i8 [ %tmp88, %bb104 ], [ %c.4, %bb75 ], [ %tmp.upgrd.3, %bb46 ], [ undef, %bb37 ], [ undef, %cond_true41 ], [ %c.4, %cond_true82 ]           ; <i8> [#uses=2]
151         %tmp116 = load i32* @qsz                ; <i32> [#uses=2]
152         %tmp118 = getelementptr i8* %min.1, i32 %tmp116         ; <i8*> [#uses=9]
153         %tmp122 = icmp ult i8* %tmp118, %tmp9           ; <i1> [#uses=1]
154         br i1 %tmp122, label %bb66, label %return
155
156 return:         ; preds = %bb115, %entry
157         ret i32 undef
158 }
159
160 declare i32 @qste(i8*, i8*)
161
162 declare i32 @comparee(%struct.edgeBox*, %struct.edgeBox*)