• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -scalarrepl -S | not grep { = alloca}
2; rdar://6417724
3; Instcombine shouldn't do anything to this function that prevents promoting the allocas inside it.
4
5target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
6target triple = "i386-apple-darwin9.6"
7
8%"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >" = type { i32* }
9%"struct.std::_Vector_base<int,std::allocator<int> >" = type { %"struct.std::_Vector_base<int,std::allocator<int> >::_Vector_impl" }
10%"struct.std::_Vector_base<int,std::allocator<int> >::_Vector_impl" = type { i32*, i32*, i32* }
11%"struct.std::bidirectional_iterator_tag" = type <{ i8 }>
12%"struct.std::forward_iterator_tag" = type <{ i8 }>
13%"struct.std::input_iterator_tag" = type <{ i8 }>
14%"struct.std::random_access_iterator_tag" = type <{ i8 }>
15%"struct.std::vector<int,std::allocator<int> >" = type { %"struct.std::_Vector_base<int,std::allocator<int> >" }
16
17define i32* @_Z3fooRSt6vectorIiSaIiEE(%"struct.std::vector<int,std::allocator<int> >"* %X) {
18entry:
19  %0 = alloca %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"
20  %__first_addr.i.i = alloca %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"
21  %__last_addr.i.i = alloca %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"
22  %unnamed_arg.i = alloca %"struct.std::bidirectional_iterator_tag", align 8
23  %1 = alloca %"struct.std::bidirectional_iterator_tag"
24  %__first_addr.i = alloca %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"
25  %2 = alloca %"struct.std::bidirectional_iterator_tag"
26  %3 = alloca %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"
27  %4 = alloca i32
28  %"alloca point" = bitcast i32 0 to i32
29  store i32 42, i32* %4, align 4
30  %5 = getelementptr %"struct.std::vector<int,std::allocator<int> >"* %X, i32 0, i32 0
31  %6 = getelementptr %"struct.std::_Vector_base<int,std::allocator<int> >"* %5, i32 0, i32 0
32  %7 = getelementptr %"struct.std::_Vector_base<int,std::allocator<int> >::_Vector_impl"* %6, i32 0, i32 1
33  %8 = load i32** %7, align 4
34  %9 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %3, i32 0, i32 0
35  store i32* %8, i32** %9, align 4
36  %10 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %3, i32 0, i32 0
37  %11 = load i32** %10, align 4
38  %tmp2.i = ptrtoint i32* %11 to i32
39  %tmp1.i = inttoptr i32 %tmp2.i to i32*
40  %tmp3 = ptrtoint i32* %tmp1.i to i32
41  %tmp2 = inttoptr i32 %tmp3 to i32*
42  %12 = getelementptr %"struct.std::vector<int,std::allocator<int> >"* %X, i32 0, i32 0
43  %13 = getelementptr %"struct.std::_Vector_base<int,std::allocator<int> >"* %12, i32 0, i32 0
44  %14 = getelementptr %"struct.std::_Vector_base<int,std::allocator<int> >::_Vector_impl"* %13, i32 0, i32 0
45  %15 = load i32** %14, align 4
46  %16 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %0, i32 0, i32 0
47  store i32* %15, i32** %16, align 4
48  %17 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %0, i32 0, i32 0
49  %18 = load i32** %17, align 4
50  %tmp2.i17 = ptrtoint i32* %18 to i32
51  %tmp1.i18 = inttoptr i32 %tmp2.i17 to i32*
52  %tmp8 = ptrtoint i32* %tmp1.i18 to i32
53  %tmp6 = inttoptr i32 %tmp8 to i32*
54  %19 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i, i32 0, i32 0
55  store i32* %tmp6, i32** %19
56  %20 = getelementptr %"struct.std::bidirectional_iterator_tag"* %1, i32 0, i32 0
57  %21 = load i8* %20, align 1
58  %22 = or i8 %21, 0
59  %23 = or i8 %22, 0
60  %24 = or i8 %23, 0
61  %25 = getelementptr %"struct.std::bidirectional_iterator_tag"* %2, i32 0, i32 0
62  store i8 0, i8* %25, align 1
63  %elt.i = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i, i32 0, i32 0
64  %val.i = load i32** %elt.i
65  %tmp.i = bitcast %"struct.std::bidirectional_iterator_tag"* %unnamed_arg.i to i8*
66  %tmp9.i = bitcast %"struct.std::bidirectional_iterator_tag"* %2 to i8*
67  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp.i, i8* %tmp9.i, i64 1, i32 1, i1 false)
68  %26 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
69  store i32* %val.i, i32** %26
70  %27 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__last_addr.i.i, i32 0, i32 0
71  store i32* %tmp2, i32** %27
72  %28 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__last_addr.i.i, i32 0, i32 0
73  %29 = load i32** %28, align 4
74  %30 = ptrtoint i32* %29 to i32
75  %31 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
76  %32 = load i32** %31, align 4
77  %33 = ptrtoint i32* %32 to i32
78  %34 = sub i32 %30, %33
79  %35 = ashr i32 %34, 2
80  %36 = ashr i32 %35, 2
81  br label %bb12.i.i
82
83bb.i.i:                                           ; preds = %bb12.i.i
84  %37 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
85  %38 = load i32** %37, align 4
86  %39 = load i32* %38, align 4
87  %40 = load i32* %4, align 4
88  %41 = icmp eq i32 %39, %40
89  %42 = zext i1 %41 to i8
90  %toBool.i.i = icmp ne i8 %42, 0
91  br i1 %toBool.i.i, label %bb1.i.i, label %bb2.i.i
92
93bb1.i.i:                                          ; preds = %bb.i.i
94  %43 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
95  %44 = load i32** %43, align 4
96  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
97
98bb2.i.i:                                          ; preds = %bb.i.i
99  %45 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
100  %46 = load i32** %45, align 4
101  %47 = getelementptr i32* %46, i64 1
102  %48 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
103  store i32* %47, i32** %48, align 4
104  %49 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
105  %50 = load i32** %49, align 4
106  %51 = load i32* %50, align 4
107  %52 = load i32* %4, align 4
108  %53 = icmp eq i32 %51, %52
109  %54 = zext i1 %53 to i8
110  %toBool3.i.i = icmp ne i8 %54, 0
111  br i1 %toBool3.i.i, label %bb4.i.i, label %bb5.i.i
112
113bb4.i.i:                                          ; preds = %bb2.i.i
114  %55 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
115  %56 = load i32** %55, align 4
116  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
117
118bb5.i.i:                                          ; preds = %bb2.i.i
119  %57 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
120  %58 = load i32** %57, align 4
121  %59 = getelementptr i32* %58, i64 1
122  %60 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
123  store i32* %59, i32** %60, align 4
124  %61 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
125  %62 = load i32** %61, align 4
126  %63 = load i32* %62, align 4
127  %64 = load i32* %4, align 4
128  %65 = icmp eq i32 %63, %64
129  %66 = zext i1 %65 to i8
130  %toBool6.i.i = icmp ne i8 %66, 0
131  br i1 %toBool6.i.i, label %bb7.i.i, label %bb8.i.i
132
133bb7.i.i:                                          ; preds = %bb5.i.i
134  %67 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
135  %68 = load i32** %67, align 4
136  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
137
138bb8.i.i:                                          ; preds = %bb5.i.i
139  %69 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
140  %70 = load i32** %69, align 4
141  %71 = getelementptr i32* %70, i64 1
142  %72 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
143  store i32* %71, i32** %72, align 4
144  %73 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
145  %74 = load i32** %73, align 4
146  %75 = load i32* %74, align 4
147  %76 = load i32* %4, align 4
148  %77 = icmp eq i32 %75, %76
149  %78 = zext i1 %77 to i8
150  %toBool9.i.i = icmp ne i8 %78, 0
151  br i1 %toBool9.i.i, label %bb10.i.i, label %bb11.i.i
152
153bb10.i.i:                                         ; preds = %bb8.i.i
154  %79 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
155  %80 = load i32** %79, align 4
156  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
157
158bb11.i.i:                                         ; preds = %bb8.i.i
159  %81 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
160  %82 = load i32** %81, align 4
161  %83 = getelementptr i32* %82, i64 1
162  %84 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
163  store i32* %83, i32** %84, align 4
164  %85 = sub i32 %__trip_count.0.i.i, 1
165  br label %bb12.i.i
166
167bb12.i.i:                                         ; preds = %bb11.i.i, %entry
168  %__trip_count.0.i.i = phi i32 [ %36, %entry ], [ %85, %bb11.i.i ]
169  %86 = icmp sgt i32 %__trip_count.0.i.i, 0
170  br i1 %86, label %bb.i.i, label %bb13.i.i
171
172bb13.i.i:                                         ; preds = %bb12.i.i
173  %87 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__last_addr.i.i, i32 0, i32 0
174  %88 = load i32** %87, align 4
175  %89 = ptrtoint i32* %88 to i32
176  %90 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
177  %91 = load i32** %90, align 4
178  %92 = ptrtoint i32* %91 to i32
179  %93 = sub i32 %89, %92
180  %94 = ashr i32 %93, 2
181  switch i32 %94, label %bb26.i.i [
182    i32 1, label %bb22.i.i
183    i32 2, label %bb18.i.i
184    i32 3, label %bb14.i.i
185  ]
186
187bb14.i.i:                                         ; preds = %bb13.i.i
188  %95 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
189  %96 = load i32** %95, align 4
190  %97 = load i32* %96, align 4
191  %98 = load i32* %4, align 4
192  %99 = icmp eq i32 %97, %98
193  %100 = zext i1 %99 to i8
194  %toBool15.i.i = icmp ne i8 %100, 0
195  br i1 %toBool15.i.i, label %bb16.i.i, label %bb17.i.i
196
197bb16.i.i:                                         ; preds = %bb14.i.i
198  %101 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
199  %102 = load i32** %101, align 4
200  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
201
202bb17.i.i:                                         ; preds = %bb14.i.i
203  %103 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
204  %104 = load i32** %103, align 4
205  %105 = getelementptr i32* %104, i64 1
206  %106 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
207  store i32* %105, i32** %106, align 4
208  br label %bb18.i.i
209
210bb18.i.i:                                         ; preds = %bb17.i.i, %bb13.i.i
211  %107 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
212  %108 = load i32** %107, align 4
213  %109 = load i32* %108, align 4
214  %110 = load i32* %4, align 4
215  %111 = icmp eq i32 %109, %110
216  %112 = zext i1 %111 to i8
217  %toBool19.i.i = icmp ne i8 %112, 0
218  br i1 %toBool19.i.i, label %bb20.i.i, label %bb21.i.i
219
220bb20.i.i:                                         ; preds = %bb18.i.i
221  %113 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
222  %114 = load i32** %113, align 4
223  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
224
225bb21.i.i:                                         ; preds = %bb18.i.i
226  %115 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
227  %116 = load i32** %115, align 4
228  %117 = getelementptr i32* %116, i64 1
229  %118 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
230  store i32* %117, i32** %118, align 4
231  br label %bb22.i.i
232
233bb22.i.i:                                         ; preds = %bb21.i.i, %bb13.i.i
234  %119 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
235  %120 = load i32** %119, align 4
236  %121 = load i32* %120, align 4
237  %122 = load i32* %4, align 4
238  %123 = icmp eq i32 %121, %122
239  %124 = zext i1 %123 to i8
240  %toBool23.i.i = icmp ne i8 %124, 0
241  br i1 %toBool23.i.i, label %bb24.i.i, label %bb25.i.i
242
243bb24.i.i:                                         ; preds = %bb22.i.i
244  %125 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
245  %126 = load i32** %125, align 4
246  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
247
248bb25.i.i:                                         ; preds = %bb22.i.i
249  %127 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
250  %128 = load i32** %127, align 4
251  %129 = getelementptr i32* %128, i64 1
252  %130 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__first_addr.i.i, i32 0, i32 0
253  store i32* %129, i32** %130, align 4
254  br label %bb26.i.i
255
256bb26.i.i:                                         ; preds = %bb25.i.i, %bb13.i.i
257  %131 = getelementptr %"struct.__gnu_cxx::__normal_iterator<int*,std::vector<int, std::allocator<int> > >"* %__last_addr.i.i, i32 0, i32 0
258  %132 = load i32** %131, align 4
259  br label %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
260
261_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit: ; preds = %bb26.i.i, %bb24.i.i, %bb20.i.i, %bb16.i.i, %bb10.i.i, %bb7.i.i, %bb4.i.i, %bb1.i.i
262  %.0.0.i.i = phi i32* [ %132, %bb26.i.i ], [ %126, %bb24.i.i ], [ %114, %bb20.i.i ], [ %102, %bb16.i.i ], [ %80, %bb10.i.i ], [ %68, %bb7.i.i ], [ %56, %bb4.i.i ], [ %44, %bb1.i.i ]
263  %tmp2.i.i = ptrtoint i32* %.0.0.i.i to i32
264  %tmp1.i.i = inttoptr i32 %tmp2.i.i to i32*
265  %tmp4.i = ptrtoint i32* %tmp1.i.i to i32
266  %tmp3.i = inttoptr i32 %tmp4.i to i32*
267  %tmp8.i = ptrtoint i32* %tmp3.i to i32
268  %tmp6.i = inttoptr i32 %tmp8.i to i32*
269  %tmp12 = ptrtoint i32* %tmp6.i to i32
270  %tmp10 = inttoptr i32 %tmp12 to i32*
271  %tmp16 = ptrtoint i32* %tmp10 to i32
272  br label %return
273
274return:                                           ; preds = %_ZSt4findIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET_S7_S7_RKT0_.exit
275  %tmp14 = inttoptr i32 %tmp16 to i32*
276  ret i32* %tmp14
277}
278
279declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
280