1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -p dse -S %s | FileCheck %s
4 target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
6 define void @widget(ptr %a) {
7 ; CHECK-LABEL: define void @widget(
8 ; CHECK-SAME: ptr [[A:%.*]]) {
10 ; CHECK-NEXT: [[CALL1:%.*]] = tail call noalias ptr @malloc(i64 0)
11 ; CHECK-NEXT: store ptr [[CALL1]], ptr [[A]], align 8
12 ; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[A]], align 8
13 ; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr [[LOAD]], align 8
14 ; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr i8, ptr [[CALL1]], i64 0
15 ; CHECK-NEXT: [[GETELEMENTPTR3:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR]], i64 1
16 ; CHECK-NEXT: [[GETELEMENTPTR4:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR]], i64 8
17 ; CHECK-NEXT: store i16 0, ptr [[GETELEMENTPTR4]], align 4
18 ; CHECK-NEXT: [[GETELEMENTPTR5:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR]], i64 12
19 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
20 ; CHECK-NEXT: [[LOAD6:%.*]] = load i32, ptr inttoptr (i64 4 to ptr), align 4
21 ; CHECK-NEXT: br label [[BB48:%.*]]
23 ; CHECK-NEXT: br label [[BB9:%.*]]
25 ; CHECK-NEXT: br label [[BB53:%.*]]
27 ; CHECK-NEXT: [[PHI:%.*]] = phi ptr [ [[CALL1]], [[BB7:%.*]] ], [ [[A]], [[BB43:%.*]] ]
28 ; CHECK-NEXT: [[GETELEMENTPTR10:%.*]] = getelementptr i8, ptr [[PHI]], i64 0
29 ; CHECK-NEXT: [[GETELEMENTPTR11:%.*]] = getelementptr i8, ptr [[PHI]], i64 0
30 ; CHECK-NEXT: [[GETELEMENTPTR12:%.*]] = getelementptr i8, ptr [[PHI]], i64 0
31 ; CHECK-NEXT: [[GETELEMENTPTR13:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 1
32 ; CHECK-NEXT: store i8 0, ptr [[CALL1]], align 1
33 ; CHECK-NEXT: br label [[BB29:%.*]]
35 ; CHECK-NEXT: [[GETELEMENTPTR15:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR10]], i64 8
36 ; CHECK-NEXT: [[LOAD16:%.*]] = load i16, ptr [[CALL1]], align 4
37 ; CHECK-NEXT: br i1 false, label [[BB22:%.*]], label [[BB17:%.*]]
39 ; CHECK-NEXT: [[GETELEMENTPTR18:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR11]], i64 8
40 ; CHECK-NEXT: [[LOAD19:%.*]] = load i16, ptr [[CALL1]], align 4
41 ; CHECK-NEXT: [[GETELEMENTPTR20:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 8
42 ; CHECK-NEXT: store i16 0, ptr [[CALL1]], align 4
43 ; CHECK-NEXT: [[GETELEMENTPTR21:%.*]] = getelementptr i8, ptr [[PHI]], i64 0
44 ; CHECK-NEXT: br label [[BB25:%.*]]
46 ; CHECK-NEXT: [[GETELEMENTPTR23:%.*]] = getelementptr i8, ptr [[PHI]], i64 0
47 ; CHECK-NEXT: [[GETELEMENTPTR24:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR23]], i64 12
48 ; CHECK-NEXT: br label [[BB25]]
50 ; CHECK-NEXT: [[PHI26:%.*]] = phi ptr [ [[A]], [[BB17]] ], [ [[CALL1]], [[BB22]] ]
51 ; CHECK-NEXT: [[PHI27:%.*]] = phi ptr [ [[CALL1]], [[BB17]] ], [ [[CALL1]], [[BB22]] ]
52 ; CHECK-NEXT: [[PHI28:%.*]] = phi ptr [ [[CALL1]], [[BB17]] ], [ [[CALL1]], [[BB22]] ]
53 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
54 ; CHECK-NEXT: br label [[BB29]]
56 ; CHECK-NEXT: [[PHI30:%.*]] = phi ptr [ [[CALL1]], [[BB9]] ], [ [[CALL1]], [[BB25]] ]
57 ; CHECK-NEXT: [[PHI31:%.*]] = phi ptr [ [[CALL1]], [[BB9]] ], [ [[CALL1]], [[BB25]] ]
58 ; CHECK-NEXT: [[LOAD32:%.*]] = load i8, ptr [[CALL1]], align 4
59 ; CHECK-NEXT: [[LOAD33:%.*]] = load i8, ptr [[CALL1]], align 4
60 ; CHECK-NEXT: [[GETELEMENTPTR34:%.*]] = getelementptr i8, ptr [[PHI31]], i64 12
61 ; CHECK-NEXT: [[GETELEMENTPTR35:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 12
62 ; CHECK-NEXT: br label [[BB86:%.*]]
64 ; CHECK-NEXT: [[GETELEMENTPTR37:%.*]] = getelementptr i8, ptr [[PHI30]], i64 12
65 ; CHECK-NEXT: br label [[BB38:%.*]]
67 ; CHECK-NEXT: [[GETELEMENTPTR39:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR34]], i64 0, i64 0
68 ; CHECK-NEXT: [[LOAD40:%.*]] = load i32, ptr [[CALL1]], align 4
69 ; CHECK-NEXT: [[GETELEMENTPTR41:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR37]], i64 0, i64 0
70 ; CHECK-NEXT: [[LOAD42:%.*]] = load i32, ptr [[CALL1]], align 4
71 ; CHECK-NEXT: br label [[BB38]]
73 ; CHECK-NEXT: [[GETELEMENTPTR44:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 8
74 ; CHECK-NEXT: [[LOAD45:%.*]] = load i16, ptr [[CALL1]], align 4
75 ; CHECK-NEXT: store i16 0, ptr [[CALL1]], align 4
76 ; CHECK-NEXT: store i8 0, ptr [[CALL1]], align 4
77 ; CHECK-NEXT: [[GETELEMENTPTR46:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 12
78 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
79 ; CHECK-NEXT: [[GETELEMENTPTR47:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR12]], i64 16
80 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
81 ; CHECK-NEXT: br label [[BB9]]
83 ; CHECK-NEXT: [[GETELEMENTPTR49:%.*]] = getelementptr i8, ptr [[CALL1]], i64 0
84 ; CHECK-NEXT: [[GETELEMENTPTR50:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR49]], i64 1
85 ; CHECK-NEXT: [[GETELEMENTPTR51:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR49]], i64 8
86 ; CHECK-NEXT: [[GETELEMENTPTR52:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR49]], i64 12
87 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
88 ; CHECK-NEXT: br label [[BB48]]
90 ; CHECK-NEXT: [[PHI54:%.*]] = phi ptr [ [[CALL1]], [[BB8:%.*]] ], [ [[A]], [[BB71:%.*]] ]
91 ; CHECK-NEXT: [[GETELEMENTPTR55:%.*]] = getelementptr i8, ptr [[PHI54]], i64 0
92 ; CHECK-NEXT: [[GETELEMENTPTR56:%.*]] = getelementptr i8, ptr [[PHI54]], i64 0
93 ; CHECK-NEXT: [[GETELEMENTPTR57:%.*]] = getelementptr i8, ptr [[PHI54]], i64 0
94 ; CHECK-NEXT: [[GETELEMENTPTR58:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 1
95 ; CHECK-NEXT: br label [[BB71]]
97 ; CHECK-NEXT: [[GETELEMENTPTR60:%.*]] = getelementptr i8, ptr [[PHI54]], i64 0
98 ; CHECK-NEXT: [[GETELEMENTPTR61:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR60]], i64 12
99 ; CHECK-NEXT: br label [[BB67:%.*]]
101 ; CHECK-NEXT: [[GETELEMENTPTR63:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR56]], i64 8
102 ; CHECK-NEXT: [[LOAD64:%.*]] = load i16, ptr [[CALL1]], align 4
103 ; CHECK-NEXT: [[GETELEMENTPTR65:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 8
104 ; CHECK-NEXT: store i16 0, ptr [[CALL1]], align 4
105 ; CHECK-NEXT: [[GETELEMENTPTR66:%.*]] = getelementptr i8, ptr [[PHI54]], i64 0
106 ; CHECK-NEXT: br label [[BB67]]
108 ; CHECK-NEXT: [[PHI68:%.*]] = phi ptr [ [[A]], [[BB62:%.*]] ], [ [[CALL1]], [[BB59:%.*]] ]
109 ; CHECK-NEXT: [[PHI69:%.*]] = phi ptr [ [[CALL1]], [[BB62]] ], [ [[CALL1]], [[BB59]] ]
110 ; CHECK-NEXT: [[PHI70:%.*]] = phi ptr [ [[CALL1]], [[BB62]] ], [ [[CALL1]], [[BB59]] ]
111 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
112 ; CHECK-NEXT: br label [[BB71]]
114 ; CHECK-NEXT: [[PHI72:%.*]] = phi ptr [ [[CALL1]], [[BB53]] ], [ [[CALL1]], [[BB67]] ]
115 ; CHECK-NEXT: [[PHI73:%.*]] = phi ptr [ [[CALL1]], [[BB53]] ], [ [[CALL1]], [[BB67]] ]
116 ; CHECK-NEXT: [[LOAD74:%.*]] = load i8, ptr [[CALL1]], align 4
117 ; CHECK-NEXT: [[LOAD75:%.*]] = load i8, ptr [[CALL1]], align 4
118 ; CHECK-NEXT: [[GETELEMENTPTR76:%.*]] = getelementptr i8, ptr [[PHI72]], i64 12
119 ; CHECK-NEXT: [[GETELEMENTPTR77:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 12
120 ; CHECK-NEXT: [[GETELEMENTPTR78:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR76]], i64 0, i64 0
121 ; CHECK-NEXT: [[LOAD79:%.*]] = load i32, ptr [[CALL1]], align 4
122 ; CHECK-NEXT: [[GETELEMENTPTR80:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR77]], i64 0, i64 0
123 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
124 ; CHECK-NEXT: [[LOAD81:%.*]] = load i8, ptr [[CALL1]], align 4
125 ; CHECK-NEXT: [[GETELEMENTPTR82:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 8
126 ; CHECK-NEXT: [[LOAD83:%.*]] = load i16, ptr [[CALL1]], align 4
127 ; CHECK-NEXT: store i16 0, ptr [[CALL1]], align 4
128 ; CHECK-NEXT: store i8 0, ptr [[CALL1]], align 4
129 ; CHECK-NEXT: [[GETELEMENTPTR84:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 12
130 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
131 ; CHECK-NEXT: [[GETELEMENTPTR85:%.*]] = getelementptr i8, ptr [[GETELEMENTPTR57]], i64 16
132 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
133 ; CHECK-NEXT: br label [[BB53]]
135 ; CHECK-NEXT: [[GETELEMENTPTR87:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR34]], i64 0, i64 0
136 ; CHECK-NEXT: [[LOAD88:%.*]] = load i32, ptr [[CALL1]], align 4
137 ; CHECK-NEXT: [[GETELEMENTPTR89:%.*]] = getelementptr [0 x i32], ptr [[GETELEMENTPTR35]], i64 0, i64 0
138 ; CHECK-NEXT: store i32 0, ptr [[CALL1]], align 4
139 ; CHECK-NEXT: br label [[BB86]]
142 %call = tail call ptr @malloc(i64 1)
143 tail call void @llvm.memset.p0.i64(ptr %call, i8 0, i64 1, i1 false)
144 %call1 = tail call noalias ptr @malloc(i64 0)
145 store ptr %call1, ptr %a, align 8
146 %load = load ptr, ptr %a, align 8
147 %load2 = load i32, ptr %load, align 8
148 %getelementptr = getelementptr i8, ptr %call1, i64 0
149 %getelementptr3 = getelementptr i8, ptr %getelementptr, i64 1
150 store i8 0, ptr %call1, align 1
151 %getelementptr4 = getelementptr i8, ptr %getelementptr, i64 8
152 store i16 0, ptr %getelementptr4, align 4
153 %getelementptr5 = getelementptr i8, ptr %getelementptr, i64 12
154 store i32 0, ptr %call1, align 4
155 %load6 = load i32, ptr inttoptr (i64 4 to ptr), align 4
158 bb7: ; No predecessors!
161 bb8: ; No predecessors!
164 bb9: ; preds = %bb43, %bb7
165 %phi = phi ptr [ %call1, %bb7 ], [ %a, %bb43 ]
166 %getelementptr10 = getelementptr i8, ptr %phi, i64 0
167 %getelementptr11 = getelementptr i8, ptr %phi, i64 0
168 %getelementptr12 = getelementptr i8, ptr %phi, i64 0
169 %getelementptr13 = getelementptr i8, ptr %getelementptr12, i64 1
170 store i8 0, ptr %call1, align 1
173 bb14: ; No predecessors!
174 %getelementptr15 = getelementptr i8, ptr %getelementptr10, i64 8
175 %load16 = load i16, ptr %call1, align 4
176 br i1 false, label %bb22, label %bb17
178 bb17: ; preds = %bb14
179 %getelementptr18 = getelementptr i8, ptr %getelementptr11, i64 8
180 %load19 = load i16, ptr %call1, align 4
181 %getelementptr20 = getelementptr i8, ptr %getelementptr12, i64 8
182 store i16 0, ptr %call1, align 4
183 %getelementptr21 = getelementptr i8, ptr %phi, i64 0
186 bb22: ; preds = %bb14
187 %getelementptr23 = getelementptr i8, ptr %phi, i64 0
188 %getelementptr24 = getelementptr i8, ptr %getelementptr23, i64 12
191 bb25: ; preds = %bb22, %bb17
192 %phi26 = phi ptr [ %a, %bb17 ], [ %call1, %bb22 ]
193 %phi27 = phi ptr [ %call1, %bb17 ], [ %call1, %bb22 ]
194 %phi28 = phi ptr [ %call1, %bb17 ], [ %call1, %bb22 ]
195 store i32 0, ptr %call1, align 4
198 bb29: ; preds = %bb25, %bb9
199 %phi30 = phi ptr [ %call1, %bb9 ], [ %call1, %bb25 ]
200 %phi31 = phi ptr [ %call1, %bb9 ], [ %call1, %bb25 ]
201 %load32 = load i8, ptr %call1, align 4
202 %load33 = load i8, ptr %call1, align 4
203 %getelementptr34 = getelementptr i8, ptr %phi31, i64 12
204 %getelementptr35 = getelementptr i8, ptr %getelementptr12, i64 12
207 bb36: ; No predecessors!
208 %getelementptr37 = getelementptr i8, ptr %phi30, i64 12
211 bb38: ; preds = %bb38, %bb36
212 %getelementptr39 = getelementptr [0 x i32], ptr %getelementptr34, i64 0, i64 0
213 %load40 = load i32, ptr %call1, align 4
214 %getelementptr41 = getelementptr [0 x i32], ptr %getelementptr37, i64 0, i64 0
215 %load42 = load i32, ptr %call1, align 4
218 bb43: ; No predecessors!
219 %getelementptr44 = getelementptr i8, ptr %getelementptr12, i64 8
220 %load45 = load i16, ptr %call1, align 4
221 store i16 0, ptr %call1, align 4
222 store i8 0, ptr %call1, align 4
223 %getelementptr46 = getelementptr i8, ptr %getelementptr12, i64 12
224 store i32 0, ptr %call1, align 4
225 %getelementptr47 = getelementptr i8, ptr %getelementptr12, i64 16
226 store i32 0, ptr %call1, align 4
229 bb48: ; preds = %bb48, %bb
230 %getelementptr49 = getelementptr i8, ptr %call1, i64 0
231 %getelementptr50 = getelementptr i8, ptr %getelementptr49, i64 1
232 store i8 0, ptr %call1, align 1
233 %getelementptr51 = getelementptr i8, ptr %getelementptr49, i64 8
234 store i16 0, ptr %call1, align 4
235 %getelementptr52 = getelementptr i8, ptr %getelementptr49, i64 12
236 store i32 0, ptr %call1, align 4
239 bb53: ; preds = %bb71, %bb8
240 %phi54 = phi ptr [ %call1, %bb8 ], [ %a, %bb71 ]
241 %getelementptr55 = getelementptr i8, ptr %phi54, i64 0
242 %getelementptr56 = getelementptr i8, ptr %phi54, i64 0
243 %getelementptr57 = getelementptr i8, ptr %phi54, i64 0
244 %getelementptr58 = getelementptr i8, ptr %getelementptr57, i64 1
247 bb59: ; No predecessors!
248 %getelementptr60 = getelementptr i8, ptr %phi54, i64 0
249 %getelementptr61 = getelementptr i8, ptr %getelementptr60, i64 12
252 bb62: ; No predecessors!
253 %getelementptr63 = getelementptr i8, ptr %getelementptr56, i64 8
254 %load64 = load i16, ptr %call1, align 4
255 %getelementptr65 = getelementptr i8, ptr %getelementptr57, i64 8
256 store i16 0, ptr %call1, align 4
257 %getelementptr66 = getelementptr i8, ptr %phi54, i64 0
260 bb67: ; preds = %bb62, %bb59
261 %phi68 = phi ptr [ %a, %bb62 ], [ %call1, %bb59 ]
262 %phi69 = phi ptr [ %call1, %bb62 ], [ %call1, %bb59 ]
263 %phi70 = phi ptr [ %call1, %bb62 ], [ %call1, %bb59 ]
264 store i32 0, ptr %call1, align 4
267 bb71: ; preds = %bb67, %bb53
268 %phi72 = phi ptr [ %call1, %bb53 ], [ %call1, %bb67 ]
269 %phi73 = phi ptr [ %call1, %bb53 ], [ %call1, %bb67 ]
270 %load74 = load i8, ptr %call1, align 4
271 %load75 = load i8, ptr %call1, align 4
272 %getelementptr76 = getelementptr i8, ptr %phi72, i64 12
273 %getelementptr77 = getelementptr i8, ptr %getelementptr57, i64 12
274 %getelementptr78 = getelementptr [0 x i32], ptr %getelementptr76, i64 0, i64 0
275 %load79 = load i32, ptr %call1, align 4
276 %getelementptr80 = getelementptr [0 x i32], ptr %getelementptr77, i64 0, i64 0
277 store i32 0, ptr %call1, align 4
278 %load81 = load i8, ptr %call1, align 4
279 %getelementptr82 = getelementptr i8, ptr %getelementptr57, i64 8
280 %load83 = load i16, ptr %call1, align 4
281 store i16 0, ptr %call1, align 4
282 store i8 0, ptr %call1, align 4
283 %getelementptr84 = getelementptr i8, ptr %getelementptr57, i64 12
284 store i32 0, ptr %call1, align 4
285 %getelementptr85 = getelementptr i8, ptr %getelementptr57, i64 16
286 store i32 0, ptr %call1, align 4
289 bb86: ; preds = %bb86, %bb29
290 %getelementptr87 = getelementptr [0 x i32], ptr %getelementptr34, i64 0, i64 0
291 %load88 = load i32, ptr %call1, align 4
292 %getelementptr89 = getelementptr [0 x i32], ptr %getelementptr35, i64 0, i64 0
293 store i32 0, ptr %call1, align 4
297 declare ptr @malloc(i64)
299 ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
300 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0
302 attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }