1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=aggressive-instcombine -mtriple x86_64-none-eabi -mattr=avx2 -data-layout="e-n64" -S | FileCheck %s --check-prefixes=ALL,LE
3 ; RUN: opt < %s -passes=aggressive-instcombine -mtriple x86_64-none-eabi -mattr=avx2 -data-layout="E-n64" -S | FileCheck %s --check-prefixes=ALL,BE
5 define i16 @loadCombine_2consecutive(ptr %p) {
7 ; LE-LABEL: @loadCombine_2consecutive(
8 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P:%.*]], align 1
9 ; LE-NEXT: ret i16 [[L1]]
11 ; BE-LABEL: @loadCombine_2consecutive(
12 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
13 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
14 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
15 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
16 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
17 ; BE-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
18 ; BE-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
19 ; BE-NEXT: ret i16 [[O1]]
21 %p1 = getelementptr i8, ptr %p, i32 1
23 %l2 = load i8, ptr %p1
24 %e1 = zext i8 %l1 to i16
25 %e2 = zext i8 %l2 to i16
31 define i16 @loadCombine_2consecutive_BE(ptr %p) {
32 ; LE-LABEL: @loadCombine_2consecutive_BE(
33 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
34 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
35 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
36 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
37 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
38 ; LE-NEXT: [[S1:%.*]] = shl i16 [[E1]], 8
39 ; LE-NEXT: [[O1:%.*]] = or i16 [[S1]], [[E2]]
40 ; LE-NEXT: ret i16 [[O1]]
42 ; BE-LABEL: @loadCombine_2consecutive_BE(
43 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P:%.*]], align 1
44 ; BE-NEXT: ret i16 [[L1]]
46 %p1 = getelementptr i8, ptr %p, i32 1
48 %l2 = load i8, ptr %p1
49 %e1 = zext i8 %l1 to i16
50 %e2 = zext i8 %l2 to i16
56 define i32 @loadCombine_4consecutive(ptr %p) {
57 ; LE-LABEL: @loadCombine_4consecutive(
58 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
59 ; LE-NEXT: ret i32 [[L1]]
61 ; BE-LABEL: @loadCombine_4consecutive(
62 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
63 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
64 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
65 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
66 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
67 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
68 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
69 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
70 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
71 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
72 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
73 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
74 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
75 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
76 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
77 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
78 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
79 ; BE-NEXT: ret i32 [[O3]]
81 %p1 = getelementptr i8, ptr %p, i32 1
82 %p2 = getelementptr i8, ptr %p, i32 2
83 %p3 = getelementptr i8, ptr %p, i32 3
85 %l2 = load i8, ptr %p1
86 %l3 = load i8, ptr %p2
87 %l4 = load i8, ptr %p3
89 %e1 = zext i8 %l1 to i32
90 %e2 = zext i8 %l2 to i32
91 %e3 = zext i8 %l3 to i32
92 %e4 = zext i8 %l4 to i32
100 %o3 = or i32 %o2, %s4
104 define i32 @loadCombine_4consecutive_BE(ptr %p) {
105 ; LE-LABEL: @loadCombine_4consecutive_BE(
106 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
107 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
108 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
109 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
110 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
111 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
112 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
113 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
114 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
115 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
116 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
117 ; LE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 24
118 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
119 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
120 ; LE-NEXT: [[O1:%.*]] = or i32 [[S1]], [[S2]]
121 ; LE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
122 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
123 ; LE-NEXT: ret i32 [[O3]]
125 ; BE-LABEL: @loadCombine_4consecutive_BE(
126 ; BE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
127 ; BE-NEXT: ret i32 [[L1]]
129 %p1 = getelementptr i8, ptr %p, i32 1
130 %p2 = getelementptr i8, ptr %p, i32 2
131 %p3 = getelementptr i8, ptr %p, i32 3
132 %l1 = load i8, ptr %p
133 %l2 = load i8, ptr %p1
134 %l3 = load i8, ptr %p2
135 %l4 = load i8, ptr %p3
137 %e1 = zext i8 %l1 to i32
138 %e2 = zext i8 %l2 to i32
139 %e3 = zext i8 %l3 to i32
140 %e4 = zext i8 %l4 to i32
142 %s1 = shl i32 %e1, 24
143 %s2 = shl i32 %e2, 16
146 %o1 = or i32 %s1, %s2
147 %o2 = or i32 %o1, %s3
148 %o3 = or i32 %o2, %e4
152 define i32 @loadCombine_4consecutive_alias(ptr %p) {
153 ; LE-LABEL: @loadCombine_4consecutive_alias(
154 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
155 ; LE-NEXT: store i8 10, ptr [[P]], align 1
156 ; LE-NEXT: ret i32 [[L1]]
158 ; BE-LABEL: @loadCombine_4consecutive_alias(
159 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
160 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
161 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
162 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
163 ; BE-NEXT: store i8 10, ptr [[P]], align 1
164 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
165 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
166 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
167 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
168 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
169 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
170 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
171 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
172 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
173 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
174 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
175 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
176 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
177 ; BE-NEXT: ret i32 [[O3]]
179 %p1 = getelementptr i8, ptr %p, i32 1
180 %p2 = getelementptr i8, ptr %p, i32 2
181 %p3 = getelementptr i8, ptr %p, i32 3
182 %l1 = load i8, ptr %p
184 %l2 = load i8, ptr %p1
185 %l3 = load i8, ptr %p2
186 %l4 = load i8, ptr %p3
188 %e1 = zext i8 %l1 to i32
189 %e2 = zext i8 %l2 to i32
190 %e3 = zext i8 %l3 to i32
191 %e4 = zext i8 %l4 to i32
194 %s3 = shl i32 %e3, 16
195 %s4 = shl i32 %e4, 24
197 %o1 = or i32 %e1, %s2
198 %o2 = or i32 %o1, %s3
199 %o3 = or i32 %o2, %s4
203 define i32 @loadCombine_4consecutive_alias_BE(ptr %p) {
204 ; LE-LABEL: @loadCombine_4consecutive_alias_BE(
205 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
206 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
207 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
208 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
209 ; LE-NEXT: store i8 10, ptr [[P]], align 1
210 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
211 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
212 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
213 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
214 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
215 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
216 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
217 ; LE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 24
218 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
219 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
220 ; LE-NEXT: [[O1:%.*]] = or i32 [[S1]], [[S2]]
221 ; LE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
222 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
223 ; LE-NEXT: ret i32 [[O3]]
225 ; BE-LABEL: @loadCombine_4consecutive_alias_BE(
226 ; BE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
227 ; BE-NEXT: store i8 10, ptr [[P]], align 1
228 ; BE-NEXT: ret i32 [[L1]]
230 %p1 = getelementptr i8, ptr %p, i32 1
231 %p2 = getelementptr i8, ptr %p, i32 2
232 %p3 = getelementptr i8, ptr %p, i32 3
233 %l1 = load i8, ptr %p
235 %l2 = load i8, ptr %p1
236 %l3 = load i8, ptr %p2
237 %l4 = load i8, ptr %p3
239 %e1 = zext i8 %l1 to i32
240 %e2 = zext i8 %l2 to i32
241 %e3 = zext i8 %l3 to i32
242 %e4 = zext i8 %l4 to i32
244 %s1 = shl i32 %e1, 24
245 %s2 = shl i32 %e2, 16
248 %o1 = or i32 %s1, %s2
249 %o2 = or i32 %o1, %s3
250 %o3 = or i32 %o2, %e4
254 define i32 @loadCombine_4consecutive_alias2(ptr %p, ptr %pstr) {
255 ; LE-LABEL: @loadCombine_4consecutive_alias2(
256 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
257 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
258 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
259 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
260 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
261 ; LE-NEXT: store i8 10, ptr [[PSTR:%.*]], align 1
262 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
263 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
264 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
265 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
266 ; LE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
267 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
268 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
269 ; LE-NEXT: ret i32 [[O3]]
271 ; BE-LABEL: @loadCombine_4consecutive_alias2(
272 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
273 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
274 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
275 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
276 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
277 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
278 ; BE-NEXT: store i8 10, ptr [[PSTR:%.*]], align 1
279 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
280 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
281 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
282 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
283 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
284 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
285 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
286 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
287 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
288 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
289 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
290 ; BE-NEXT: ret i32 [[O3]]
292 %p1 = getelementptr i8, ptr %p, i32 1
293 %p2 = getelementptr i8, ptr %p, i32 2
294 %p3 = getelementptr i8, ptr %p, i32 3
295 %l1 = load i8, ptr %p
296 %l2 = load i8, ptr %p1
297 %l3 = load i8, ptr %p2
298 store i8 10, i8* %pstr
299 %l4 = load i8, ptr %p3
301 %e1 = zext i8 %l1 to i32
302 %e2 = zext i8 %l2 to i32
303 %e3 = zext i8 %l3 to i32
304 %e4 = zext i8 %l4 to i32
307 %s3 = shl i32 %e3, 16
308 %s4 = shl i32 %e4, 24
310 %o1 = or i32 %e1, %s2
311 %o2 = or i32 %o1, %s3
312 %o3 = or i32 %o2, %s4
316 define i32 @loadCombine_4consecutive_alias2_BE(ptr %p, ptr %pstr) {
317 ; LE-LABEL: @loadCombine_4consecutive_alias2_BE(
318 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
319 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
320 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
321 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
322 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
323 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
324 ; LE-NEXT: store i8 10, ptr [[PSTR:%.*]], align 1
325 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
326 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
327 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
328 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
329 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
330 ; LE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 24
331 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
332 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
333 ; LE-NEXT: [[O1:%.*]] = or i32 [[S1]], [[S2]]
334 ; LE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
335 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
336 ; LE-NEXT: ret i32 [[O3]]
338 ; BE-LABEL: @loadCombine_4consecutive_alias2_BE(
339 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
340 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
341 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
342 ; BE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
343 ; BE-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 16
344 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
345 ; BE-NEXT: store i8 10, ptr [[PSTR:%.*]], align 1
346 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
347 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
348 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
349 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
350 ; BE-NEXT: [[O2:%.*]] = or i32 [[TMP2]], [[S3]]
351 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
352 ; BE-NEXT: ret i32 [[O3]]
354 %p1 = getelementptr i8, ptr %p, i32 1
355 %p2 = getelementptr i8, ptr %p, i32 2
356 %p3 = getelementptr i8, ptr %p, i32 3
357 %l1 = load i8, ptr %p
358 %l2 = load i8, ptr %p1
359 %l3 = load i8, ptr %p2
360 store i8 10, i8* %pstr
361 %l4 = load i8, ptr %p3
363 %e1 = zext i8 %l1 to i32
364 %e2 = zext i8 %l2 to i32
365 %e3 = zext i8 %l3 to i32
366 %e4 = zext i8 %l4 to i32
368 %s1 = shl i32 %e1, 24
369 %s2 = shl i32 %e2, 16
372 %o1 = or i32 %s1, %s2
373 %o2 = or i32 %o1, %s3
374 %o3 = or i32 %o2, %e4
378 define i32 @loadCombine_4consecutive_alias3(ptr %p) {
379 ; LE-LABEL: @loadCombine_4consecutive_alias3(
380 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
381 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
382 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
383 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
384 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
385 ; LE-NEXT: store i8 10, ptr [[P3]], align 1
386 ; LE-NEXT: store i8 5, ptr [[P]], align 1
387 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
388 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
389 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
390 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
391 ; LE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
392 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
393 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
394 ; LE-NEXT: ret i32 [[O3]]
396 ; BE-LABEL: @loadCombine_4consecutive_alias3(
397 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
398 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
399 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
400 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
401 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
402 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
403 ; BE-NEXT: store i8 10, ptr [[P3]], align 1
404 ; BE-NEXT: store i8 5, ptr [[P]], align 1
405 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
406 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
407 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
408 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
409 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
410 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
411 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
412 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
413 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
414 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
415 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
416 ; BE-NEXT: ret i32 [[O3]]
418 %p1 = getelementptr i8, ptr %p, i32 1
419 %p2 = getelementptr i8, ptr %p, i32 2
420 %p3 = getelementptr i8, ptr %p, i32 3
421 %l1 = load i8, ptr %p
422 %l2 = load i8, ptr %p1
423 %l3 = load i8, ptr %p2
426 %l4 = load i8, ptr %p3
428 %e1 = zext i8 %l1 to i32
429 %e2 = zext i8 %l2 to i32
430 %e3 = zext i8 %l3 to i32
431 %e4 = zext i8 %l4 to i32
434 %s3 = shl i32 %e3, 16
435 %s4 = shl i32 %e4, 24
437 %o1 = or i32 %e1, %s2
438 %o2 = or i32 %o1, %s3
439 %o3 = or i32 %o2, %s4
443 define i32 @loadCombine_4consecutive_alias3_BE(ptr %p) {
444 ; LE-LABEL: @loadCombine_4consecutive_alias3_BE(
445 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
446 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
447 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
448 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
449 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
450 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
451 ; LE-NEXT: store i8 10, ptr [[P3]], align 1
452 ; LE-NEXT: store i8 5, ptr [[P]], align 1
453 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
454 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
455 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
456 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
457 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
458 ; LE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 24
459 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
460 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
461 ; LE-NEXT: [[O1:%.*]] = or i32 [[S1]], [[S2]]
462 ; LE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
463 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
464 ; LE-NEXT: ret i32 [[O3]]
466 ; BE-LABEL: @loadCombine_4consecutive_alias3_BE(
467 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
468 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
469 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
470 ; BE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
471 ; BE-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 16
472 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
473 ; BE-NEXT: store i8 10, ptr [[P3]], align 1
474 ; BE-NEXT: store i8 5, ptr [[P]], align 1
475 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
476 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
477 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
478 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 8
479 ; BE-NEXT: [[O2:%.*]] = or i32 [[TMP2]], [[S3]]
480 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E4]]
481 ; BE-NEXT: ret i32 [[O3]]
483 %p1 = getelementptr i8, ptr %p, i32 1
484 %p2 = getelementptr i8, ptr %p, i32 2
485 %p3 = getelementptr i8, ptr %p, i32 3
486 %l1 = load i8, ptr %p
487 %l2 = load i8, ptr %p1
488 %l3 = load i8, ptr %p2
491 %l4 = load i8, ptr %p3
493 %e1 = zext i8 %l1 to i32
494 %e2 = zext i8 %l2 to i32
495 %e3 = zext i8 %l3 to i32
496 %e4 = zext i8 %l4 to i32
498 %s1 = shl i32 %e1, 24
499 %s2 = shl i32 %e2, 16
502 %o1 = or i32 %s1, %s2
503 %o2 = or i32 %o1, %s3
504 %o3 = or i32 %o2, %e4
508 define i32 @loadCombine_4consecutive_with_alias4(ptr %p, ptr %ps) {
509 ; ALL-LABEL: @loadCombine_4consecutive_with_alias4(
510 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
511 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
512 ; ALL-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
513 ; ALL-NEXT: [[PS1:%.*]] = getelementptr i8, ptr [[PS:%.*]], i32 1
514 ; ALL-NEXT: [[PS2:%.*]] = getelementptr i8, ptr [[PS]], i32 2
515 ; ALL-NEXT: [[PS3:%.*]] = getelementptr i8, ptr [[PS]], i32 3
516 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
517 ; ALL-NEXT: store i8 10, ptr [[PS]], align 1
518 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
519 ; ALL-NEXT: store i8 10, ptr [[PS1]], align 1
520 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
521 ; ALL-NEXT: store i8 10, ptr [[PS2]], align 1
522 ; ALL-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
523 ; ALL-NEXT: store i8 10, ptr [[PS3]], align 1
524 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
525 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
526 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
527 ; ALL-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
528 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
529 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
530 ; ALL-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
531 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
532 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
533 ; ALL-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
534 ; ALL-NEXT: ret i32 [[O3]]
536 %p1 = getelementptr i8, ptr %p, i32 1
537 %p2 = getelementptr i8, ptr %p, i32 2
538 %p3 = getelementptr i8, ptr %p, i32 3
539 %ps1 = getelementptr i8, ptr %ps, i32 1
540 %ps2 = getelementptr i8, ptr %ps, i32 2
541 %ps3 = getelementptr i8, ptr %ps, i32 3
542 %l1 = load i8, ptr %p
544 %l2 = load i8, ptr %p1
545 store i8 10, i8* %ps1
546 %l3 = load i8, ptr %p2
547 store i8 10, i8* %ps2
548 %l4 = load i8, ptr %p3
549 store i8 10, i8* %ps3
551 %e1 = zext i8 %l1 to i32
552 %e2 = zext i8 %l2 to i32
553 %e3 = zext i8 %l3 to i32
554 %e4 = zext i8 %l4 to i32
557 %s3 = shl i32 %e3, 16
558 %s4 = shl i32 %e4, 24
560 %o1 = or i32 %e1, %s2
561 %o2 = or i32 %o1, %s3
562 %o3 = or i32 %o2, %s4
566 declare void @use(i8)
567 declare void @use2(i32)
569 define i32 @loadCombine_4consecutive_hasOneUse1(ptr %p) {
570 ; ALL-LABEL: @loadCombine_4consecutive_hasOneUse1(
571 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
572 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
573 ; ALL-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
574 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
575 ; ALL-NEXT: call void @use(i8 [[L1]])
576 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
577 ; ALL-NEXT: call void @use(i8 [[L2]])
578 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
579 ; ALL-NEXT: call void @use(i8 [[L3]])
580 ; ALL-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
581 ; ALL-NEXT: call void @use(i8 [[L4]])
582 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
583 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
584 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
585 ; ALL-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
586 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
587 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
588 ; ALL-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
589 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
590 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
591 ; ALL-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
592 ; ALL-NEXT: ret i32 [[O3]]
594 %p1 = getelementptr i8, ptr %p, i32 1
595 %p2 = getelementptr i8, ptr %p, i32 2
596 %p3 = getelementptr i8, ptr %p, i32 3
597 %l1 = load i8, ptr %p
598 call void @use(i8 %l1)
599 %l2 = load i8, ptr %p1
600 call void @use(i8 %l2)
601 %l3 = load i8, ptr %p2
602 call void @use(i8 %l3)
603 %l4 = load i8, ptr %p3
604 call void @use(i8 %l4)
606 %e1 = zext i8 %l1 to i32
607 %e2 = zext i8 %l2 to i32
608 %e3 = zext i8 %l3 to i32
609 %e4 = zext i8 %l4 to i32
612 %s3 = shl i32 %e3, 16
613 %s4 = shl i32 %e4, 24
615 %o1 = or i32 %e1, %s2
616 %o2 = or i32 %o1, %s3
617 %o3 = or i32 %o2, %s4
621 define i32 @loadCombine_4consecutive_hasOneUse2(ptr %p) {
622 ; ALL-LABEL: @loadCombine_4consecutive_hasOneUse2(
623 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
624 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
625 ; ALL-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
626 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
627 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
628 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
629 ; ALL-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
630 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
631 ; ALL-NEXT: call void @use(i32 [[E1]])
632 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
633 ; ALL-NEXT: call void @use(i32 [[E2]])
634 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
635 ; ALL-NEXT: call void @use(i32 [[E3]])
636 ; ALL-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
637 ; ALL-NEXT: call void @use(i32 [[E4]])
638 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
639 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
640 ; ALL-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
641 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
642 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
643 ; ALL-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
644 ; ALL-NEXT: ret i32 [[O3]]
646 %p1 = getelementptr i8, ptr %p, i32 1
647 %p2 = getelementptr i8, ptr %p, i32 2
648 %p3 = getelementptr i8, ptr %p, i32 3
649 %l1 = load i8, ptr %p
650 %l2 = load i8, ptr %p1
651 %l3 = load i8, ptr %p2
652 %l4 = load i8, ptr %p3
654 %e1 = zext i8 %l1 to i32
655 call void @use(i32 %e1)
656 %e2 = zext i8 %l2 to i32
657 call void @use(i32 %e2)
658 %e3 = zext i8 %l3 to i32
659 call void @use(i32 %e3)
660 %e4 = zext i8 %l4 to i32
661 call void @use(i32 %e4)
664 %s3 = shl i32 %e3, 16
665 %s4 = shl i32 %e4, 24
667 %o1 = or i32 %e1, %s2
668 %o2 = or i32 %o1, %s3
669 %o3 = or i32 %o2, %s4
673 define i32 @loadCombine_4consecutive_hasOneUse3(ptr %p) {
674 ; ALL-LABEL: @loadCombine_4consecutive_hasOneUse3(
675 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
676 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
677 ; ALL-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
678 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
679 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
680 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
681 ; ALL-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
682 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
683 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
684 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
685 ; ALL-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
686 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
687 ; ALL-NEXT: call void @use(i32 [[S2]])
688 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
689 ; ALL-NEXT: call void @use(i32 [[S3]])
690 ; ALL-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
691 ; ALL-NEXT: call void @use(i32 [[S4]])
692 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
693 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
694 ; ALL-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
695 ; ALL-NEXT: ret i32 [[O3]]
697 %p1 = getelementptr i8, ptr %p, i32 1
698 %p2 = getelementptr i8, ptr %p, i32 2
699 %p3 = getelementptr i8, ptr %p, i32 3
700 %l1 = load i8, ptr %p
701 %l2 = load i8, ptr %p1
702 %l3 = load i8, ptr %p2
703 %l4 = load i8, ptr %p3
705 %e1 = zext i8 %l1 to i32
706 %e2 = zext i8 %l2 to i32
707 %e3 = zext i8 %l3 to i32
708 %e4 = zext i8 %l4 to i32
711 call void @use(i32 %s2)
712 %s3 = shl i32 %e3, 16
713 call void @use(i32 %s3)
714 %s4 = shl i32 %e4, 24
715 call void @use(i32 %s4)
717 %o1 = or i32 %e1, %s2
718 %o2 = or i32 %o1, %s3
719 %o3 = or i32 %o2, %s4
723 define i32 @loadCombine_4consecutive_hasOneUse4(ptr %p) {
724 ; ALL-LABEL: @loadCombine_4consecutive_hasOneUse4(
725 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
726 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
727 ; ALL-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
728 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
729 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
730 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
731 ; ALL-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
732 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
733 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
734 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
735 ; ALL-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
736 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
737 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
738 ; ALL-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
739 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
740 ; ALL-NEXT: call void @use(i32 [[O1]])
741 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
742 ; ALL-NEXT: call void @use(i32 [[O2]])
743 ; ALL-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
744 ; ALL-NEXT: ret i32 [[O3]]
746 %p1 = getelementptr i8, ptr %p, i32 1
747 %p2 = getelementptr i8, ptr %p, i32 2
748 %p3 = getelementptr i8, ptr %p, i32 3
749 %l1 = load i8, ptr %p
750 %l2 = load i8, ptr %p1
751 %l3 = load i8, ptr %p2
752 %l4 = load i8, ptr %p3
754 %e1 = zext i8 %l1 to i32
755 %e2 = zext i8 %l2 to i32
756 %e3 = zext i8 %l3 to i32
757 %e4 = zext i8 %l4 to i32
760 %s3 = shl i32 %e3, 16
761 %s4 = shl i32 %e4, 24
763 %o1 = or i32 %e1, %s2
764 call void @use(i32 %o1)
765 %o2 = or i32 %o1, %s3
766 call void @use(i32 %o2)
767 %o3 = or i32 %o2, %s4
771 define i32 @loadCombine_parLoad1(ptr %p) {
772 ; LE-LABEL: @loadCombine_parLoad1(
773 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
774 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
775 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
776 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
777 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
778 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
779 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
780 ; LE-NEXT: ret i32 [[O2]]
782 ; BE-LABEL: @loadCombine_parLoad1(
783 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
784 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
785 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
786 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
787 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
788 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
789 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
790 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
791 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
792 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
793 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
794 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
795 ; BE-NEXT: ret i32 [[O2]]
797 %p1 = getelementptr i8, ptr %p, i32 1
798 %p2 = getelementptr i8, ptr %p, i32 2
799 %l1 = load i8, ptr %p
800 %l2 = load i8, ptr %p1
801 %l3 = load i8, ptr %p2
803 %e1 = zext i8 %l1 to i32
804 %e2 = zext i8 %l2 to i32
805 %e3 = zext i8 %l3 to i32
808 %s3 = shl i32 %e3, 16
810 %o1 = or i32 %e1, %s2
811 %o2 = or i32 %o1, %s3
815 define i128 @loadCombine_i128(ptr %p) {
816 ; LE-LABEL: @loadCombine_i128(
817 ; LE-NEXT: [[P2:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 2
818 ; LE-NEXT: [[P3:%.*]] = getelementptr i32, ptr [[P]], i32 3
819 ; LE-NEXT: [[L1:%.*]] = load i64, ptr [[P]], align 4
820 ; LE-NEXT: [[TMP1:%.*]] = zext i64 [[L1]] to i128
821 ; LE-NEXT: [[L3:%.*]] = load i32, ptr [[P2]], align 4
822 ; LE-NEXT: [[L4:%.*]] = load i32, ptr [[P3]], align 4
823 ; LE-NEXT: [[E3:%.*]] = zext i32 [[L3]] to i128
824 ; LE-NEXT: [[E4:%.*]] = zext i32 [[L4]] to i128
825 ; LE-NEXT: [[S3:%.*]] = shl i128 [[E3]], 64
826 ; LE-NEXT: [[S4:%.*]] = shl i128 [[E4]], 96
827 ; LE-NEXT: [[O2:%.*]] = or i128 [[TMP1]], [[S3]]
828 ; LE-NEXT: [[O3:%.*]] = or i128 [[O2]], [[S4]]
829 ; LE-NEXT: ret i128 [[O3]]
831 ; BE-LABEL: @loadCombine_i128(
832 ; BE-NEXT: [[P1:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 1
833 ; BE-NEXT: [[P2:%.*]] = getelementptr i32, ptr [[P]], i32 2
834 ; BE-NEXT: [[P3:%.*]] = getelementptr i32, ptr [[P]], i32 3
835 ; BE-NEXT: [[L1:%.*]] = load i32, ptr [[P]], align 4
836 ; BE-NEXT: [[L2:%.*]] = load i32, ptr [[P1]], align 4
837 ; BE-NEXT: [[L3:%.*]] = load i32, ptr [[P2]], align 4
838 ; BE-NEXT: [[L4:%.*]] = load i32, ptr [[P3]], align 4
839 ; BE-NEXT: [[E1:%.*]] = zext i32 [[L1]] to i128
840 ; BE-NEXT: [[E2:%.*]] = zext i32 [[L2]] to i128
841 ; BE-NEXT: [[E3:%.*]] = zext i32 [[L3]] to i128
842 ; BE-NEXT: [[E4:%.*]] = zext i32 [[L4]] to i128
843 ; BE-NEXT: [[S2:%.*]] = shl i128 [[E2]], 32
844 ; BE-NEXT: [[S3:%.*]] = shl i128 [[E3]], 64
845 ; BE-NEXT: [[S4:%.*]] = shl i128 [[E4]], 96
846 ; BE-NEXT: [[O1:%.*]] = or i128 [[E1]], [[S2]]
847 ; BE-NEXT: [[O2:%.*]] = or i128 [[O1]], [[S3]]
848 ; BE-NEXT: [[O3:%.*]] = or i128 [[O2]], [[S4]]
849 ; BE-NEXT: ret i128 [[O3]]
851 %p1 = getelementptr i32, ptr %p, i32 1
852 %p2 = getelementptr i32, ptr %p, i32 2
853 %p3 = getelementptr i32, ptr %p, i32 3
854 %l1 = load i32, ptr %p
855 %l2 = load i32, ptr %p1
856 %l3 = load i32, ptr %p2
857 %l4 = load i32, ptr %p3
859 %e1 = zext i32 %l1 to i128
860 %e2 = zext i32 %l2 to i128
861 %e3 = zext i32 %l3 to i128
862 %e4 = zext i32 %l4 to i128
864 %s2 = shl i128 %e2, 32
865 %s3 = shl i128 %e3, 64
866 %s4 = shl i128 %e4, 96
868 %o1 = or i128 %e1, %s2
869 %o2 = or i128 %o1, %s3
870 %o3 = or i128 %o2, %s4
874 define i128 @loadCombine_i128_BE(ptr %p) {
875 ; LE-LABEL: @loadCombine_i128_BE(
876 ; LE-NEXT: [[P1:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 1
877 ; LE-NEXT: [[P2:%.*]] = getelementptr i32, ptr [[P]], i32 2
878 ; LE-NEXT: [[P3:%.*]] = getelementptr i32, ptr [[P]], i32 3
879 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P]], align 4
880 ; LE-NEXT: [[L2:%.*]] = load i32, ptr [[P1]], align 4
881 ; LE-NEXT: [[L3:%.*]] = load i32, ptr [[P2]], align 4
882 ; LE-NEXT: [[L4:%.*]] = load i32, ptr [[P3]], align 4
883 ; LE-NEXT: [[E1:%.*]] = zext i32 [[L1]] to i128
884 ; LE-NEXT: [[E2:%.*]] = zext i32 [[L2]] to i128
885 ; LE-NEXT: [[E3:%.*]] = zext i32 [[L3]] to i128
886 ; LE-NEXT: [[E4:%.*]] = zext i32 [[L4]] to i128
887 ; LE-NEXT: [[S1:%.*]] = shl i128 [[E1]], 96
888 ; LE-NEXT: [[S2:%.*]] = shl i128 [[E2]], 64
889 ; LE-NEXT: [[S3:%.*]] = shl i128 [[E3]], 32
890 ; LE-NEXT: [[O1:%.*]] = or i128 [[S1]], [[S2]]
891 ; LE-NEXT: [[O2:%.*]] = or i128 [[O1]], [[S3]]
892 ; LE-NEXT: [[O3:%.*]] = or i128 [[O2]], [[E4]]
893 ; LE-NEXT: ret i128 [[O3]]
895 ; BE-LABEL: @loadCombine_i128_BE(
896 ; BE-NEXT: [[P2:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 2
897 ; BE-NEXT: [[P3:%.*]] = getelementptr i32, ptr [[P]], i32 3
898 ; BE-NEXT: [[L1:%.*]] = load i64, ptr [[P]], align 4
899 ; BE-NEXT: [[TMP1:%.*]] = zext i64 [[L1]] to i128
900 ; BE-NEXT: [[TMP2:%.*]] = shl i128 [[TMP1]], 64
901 ; BE-NEXT: [[L3:%.*]] = load i32, ptr [[P2]], align 4
902 ; BE-NEXT: [[L4:%.*]] = load i32, ptr [[P3]], align 4
903 ; BE-NEXT: [[E3:%.*]] = zext i32 [[L3]] to i128
904 ; BE-NEXT: [[E4:%.*]] = zext i32 [[L4]] to i128
905 ; BE-NEXT: [[S3:%.*]] = shl i128 [[E3]], 32
906 ; BE-NEXT: [[O2:%.*]] = or i128 [[TMP2]], [[S3]]
907 ; BE-NEXT: [[O3:%.*]] = or i128 [[O2]], [[E4]]
908 ; BE-NEXT: ret i128 [[O3]]
910 %p1 = getelementptr i32, ptr %p, i32 1
911 %p2 = getelementptr i32, ptr %p, i32 2
912 %p3 = getelementptr i32, ptr %p, i32 3
913 %l1 = load i32, ptr %p
914 %l2 = load i32, ptr %p1
915 %l3 = load i32, ptr %p2
916 %l4 = load i32, ptr %p3
918 %e1 = zext i32 %l1 to i128
919 %e2 = zext i32 %l2 to i128
920 %e3 = zext i32 %l3 to i128
921 %e4 = zext i32 %l4 to i128
923 %s1 = shl i128 %e1, 96
924 %s2 = shl i128 %e2, 64
925 %s3 = shl i128 %e3, 32
927 %o1 = or i128 %s1, %s2
928 %o2 = or i128 %o1, %s3
929 %o3 = or i128 %o2, %e4
933 define i64 @loadCombine_i64(ptr %p) {
934 ; LE-LABEL: @loadCombine_i64(
935 ; LE-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 2
936 ; LE-NEXT: ret i64 [[L1]]
938 ; BE-LABEL: @loadCombine_i64(
939 ; BE-NEXT: [[P1:%.*]] = getelementptr i16, ptr [[P:%.*]], i32 1
940 ; BE-NEXT: [[P2:%.*]] = getelementptr i16, ptr [[P]], i32 2
941 ; BE-NEXT: [[P3:%.*]] = getelementptr i16, ptr [[P]], i32 3
942 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
943 ; BE-NEXT: [[L2:%.*]] = load i16, ptr [[P1]], align 2
944 ; BE-NEXT: [[L3:%.*]] = load i16, ptr [[P2]], align 2
945 ; BE-NEXT: [[L4:%.*]] = load i16, ptr [[P3]], align 2
946 ; BE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i64
947 ; BE-NEXT: [[E2:%.*]] = zext i16 [[L2]] to i64
948 ; BE-NEXT: [[E3:%.*]] = zext i16 [[L3]] to i64
949 ; BE-NEXT: [[E4:%.*]] = zext i16 [[L4]] to i64
950 ; BE-NEXT: [[S2:%.*]] = shl i64 [[E2]], 16
951 ; BE-NEXT: [[S3:%.*]] = shl i64 [[E3]], 32
952 ; BE-NEXT: [[S4:%.*]] = shl i64 [[E4]], 48
953 ; BE-NEXT: [[O1:%.*]] = or i64 [[E1]], [[S2]]
954 ; BE-NEXT: [[O2:%.*]] = or i64 [[O1]], [[S3]]
955 ; BE-NEXT: [[O3:%.*]] = or i64 [[O2]], [[S4]]
956 ; BE-NEXT: ret i64 [[O3]]
958 %p1 = getelementptr i16, ptr %p, i32 1
959 %p2 = getelementptr i16, ptr %p, i32 2
960 %p3 = getelementptr i16, ptr %p, i32 3
961 %l1 = load i16, ptr %p
962 %l2 = load i16, ptr %p1
963 %l3 = load i16, ptr %p2
964 %l4 = load i16, ptr %p3
966 %e1 = zext i16 %l1 to i64
967 %e2 = zext i16 %l2 to i64
968 %e3 = zext i16 %l3 to i64
969 %e4 = zext i16 %l4 to i64
971 %s2 = shl i64 %e2, 16
972 %s3 = shl i64 %e3, 32
973 %s4 = shl i64 %e4, 48
975 %o1 = or i64 %e1, %s2
976 %o2 = or i64 %o1, %s3
977 %o3 = or i64 %o2, %s4
981 define i64 @loadCombine_i64_BE(ptr %p) {
982 ; LE-LABEL: @loadCombine_i64_BE(
983 ; LE-NEXT: [[P1:%.*]] = getelementptr i16, ptr [[P:%.*]], i32 1
984 ; LE-NEXT: [[P2:%.*]] = getelementptr i16, ptr [[P]], i32 2
985 ; LE-NEXT: [[P3:%.*]] = getelementptr i16, ptr [[P]], i32 3
986 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
987 ; LE-NEXT: [[L2:%.*]] = load i16, ptr [[P1]], align 2
988 ; LE-NEXT: [[L3:%.*]] = load i16, ptr [[P2]], align 2
989 ; LE-NEXT: [[L4:%.*]] = load i16, ptr [[P3]], align 2
990 ; LE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i64
991 ; LE-NEXT: [[E2:%.*]] = zext i16 [[L2]] to i64
992 ; LE-NEXT: [[E3:%.*]] = zext i16 [[L3]] to i64
993 ; LE-NEXT: [[E4:%.*]] = zext i16 [[L4]] to i64
994 ; LE-NEXT: [[S1:%.*]] = shl i64 [[E1]], 48
995 ; LE-NEXT: [[S2:%.*]] = shl i64 [[E2]], 32
996 ; LE-NEXT: [[S3:%.*]] = shl i64 [[E3]], 16
997 ; LE-NEXT: [[O1:%.*]] = or i64 [[S1]], [[S2]]
998 ; LE-NEXT: [[O2:%.*]] = or i64 [[O1]], [[S3]]
999 ; LE-NEXT: [[O3:%.*]] = or i64 [[O2]], [[E4]]
1000 ; LE-NEXT: ret i64 [[O3]]
1002 ; BE-LABEL: @loadCombine_i64_BE(
1003 ; BE-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 2
1004 ; BE-NEXT: ret i64 [[L1]]
1006 %p1 = getelementptr i16, ptr %p, i32 1
1007 %p2 = getelementptr i16, ptr %p, i32 2
1008 %p3 = getelementptr i16, ptr %p, i32 3
1009 %l1 = load i16, ptr %p
1010 %l2 = load i16, ptr %p1
1011 %l3 = load i16, ptr %p2
1012 %l4 = load i16, ptr %p3
1014 %e1 = zext i16 %l1 to i64
1015 %e2 = zext i16 %l2 to i64
1016 %e3 = zext i16 %l3 to i64
1017 %e4 = zext i16 %l4 to i64
1019 %s1 = shl i64 %e1, 48
1020 %s2 = shl i64 %e2, 32
1021 %s3 = shl i64 %e3, 16
1023 %o1 = or i64 %s1, %s2
1024 %o2 = or i64 %o1, %s3
1025 %o3 = or i64 %o2, %e4
1029 define i16 @loadCombine_2consecutive_atomic(ptr %p) {
1030 ; ALL-LABEL: @loadCombine_2consecutive_atomic(
1031 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1032 ; ALL-NEXT: [[L1:%.*]] = load atomic i8, ptr [[P]] monotonic, align 1
1033 ; ALL-NEXT: [[L2:%.*]] = load atomic i8, ptr [[P1]] monotonic, align 1
1034 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
1035 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
1036 ; ALL-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
1037 ; ALL-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1038 ; ALL-NEXT: ret i16 [[O1]]
1040 %p1 = getelementptr i8, ptr %p, i32 1
1041 %l1 = load atomic i8, ptr %p monotonic, align 1
1042 %l2 = load atomic i8, ptr %p1 monotonic, align 1
1043 %e1 = zext i8 %l1 to i16
1044 %e2 = zext i8 %l2 to i16
1045 %s2 = shl i16 %e2, 8
1046 %o1 = or i16 %e1, %s2
1050 define i16 @loadCombine_2consecutive_volatile(ptr %p) {
1051 ; ALL-LABEL: @loadCombine_2consecutive_volatile(
1052 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1053 ; ALL-NEXT: [[L1:%.*]] = load volatile i8, ptr [[P]], align 1
1054 ; ALL-NEXT: [[L2:%.*]] = load volatile i8, ptr [[P1]], align 1
1055 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
1056 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
1057 ; ALL-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
1058 ; ALL-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1059 ; ALL-NEXT: ret i16 [[O1]]
1061 %p1 = getelementptr i8, ptr %p, i32 1
1062 %l1 = load volatile i8, ptr %p, align 1
1063 %l2 = load volatile i8, ptr %p1, align 1
1064 %e1 = zext i8 %l1 to i16
1065 %e2 = zext i8 %l2 to i16
1066 %s2 = shl i16 %e2, 8
1067 %o1 = or i16 %e1, %s2
1071 define i16 @loadCombine_2consecutive_separateBB(ptr %p) {
1072 ; ALL-LABEL: @loadCombine_2consecutive_separateBB(
1073 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1074 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1075 ; ALL-NEXT: br label [[BB2:%.*]]
1077 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1078 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
1079 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
1080 ; ALL-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
1081 ; ALL-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1082 ; ALL-NEXT: ret i16 [[O1]]
1084 %p1 = getelementptr i8, ptr %p, i32 1
1085 %l1 = load i8, ptr %p, align 1
1089 %l2 = load i8, ptr %p1, align 1
1090 %e1 = zext i8 %l1 to i16
1091 %e2 = zext i8 %l2 to i16
1092 %s2 = shl i16 %e2, 8
1093 %o1 = or i16 %e1, %s2
1097 define i16 @loadCombine_2consecutive_separateptr(ptr %p, ptr %p2) {
1098 ; ALL-LABEL: @loadCombine_2consecutive_separateptr(
1099 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P2:%.*]], i32 1
1100 ; ALL-NEXT: [[L1:%.*]] = load i8, ptr [[P:%.*]], align 1
1101 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1102 ; ALL-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
1103 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
1104 ; ALL-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
1105 ; ALL-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1106 ; ALL-NEXT: ret i16 [[O1]]
1108 %p1 = getelementptr i8, ptr %p2, i32 1
1109 %l1 = load i8, ptr %p, align 1
1110 %l2 = load i8, ptr %p1, align 1
1111 %e1 = zext i8 %l1 to i16
1112 %e2 = zext i8 %l2 to i16
1113 %s2 = shl i16 %e2, 8
1114 %o1 = or i16 %e1, %s2
1118 define i64 @load64_farLoads(ptr %ptr) {
1119 ; LE-LABEL: @load64_farLoads(
1121 ; LE-NEXT: [[TMP0:%.*]] = load i64, ptr [[PTR:%.*]], align 1
1122 ; LE-NEXT: ret i64 [[TMP0]]
1124 ; BE-LABEL: @load64_farLoads(
1126 ; BE-NEXT: [[TMP0:%.*]] = load i8, ptr [[PTR:%.*]], align 1
1127 ; BE-NEXT: [[CONV:%.*]] = zext i8 [[TMP0]] to i64
1128 ; BE-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 1
1129 ; BE-NEXT: [[TMP1:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1
1130 ; BE-NEXT: [[CONV2:%.*]] = zext i8 [[TMP1]] to i64
1131 ; BE-NEXT: [[SHL:%.*]] = shl i64 [[CONV2]], 8
1132 ; BE-NEXT: [[OR:%.*]] = or i64 [[CONV]], [[SHL]]
1133 ; BE-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 2
1134 ; BE-NEXT: [[TMP2:%.*]] = load i8, ptr [[ARRAYIDX3]], align 1
1135 ; BE-NEXT: [[CONV4:%.*]] = zext i8 [[TMP2]] to i64
1136 ; BE-NEXT: [[SHL5:%.*]] = shl i64 [[CONV4]], 16
1137 ; BE-NEXT: [[OR6:%.*]] = or i64 [[OR]], [[SHL5]]
1138 ; BE-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 3
1139 ; BE-NEXT: [[TMP3:%.*]] = load i8, ptr [[ARRAYIDX7]], align 1
1140 ; BE-NEXT: [[CONV8:%.*]] = zext i8 [[TMP3]] to i64
1141 ; BE-NEXT: [[SHL9:%.*]] = shl i64 [[CONV8]], 24
1142 ; BE-NEXT: [[OR10:%.*]] = or i64 [[OR6]], [[SHL9]]
1143 ; BE-NEXT: [[ARRAYIDX11:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 4
1144 ; BE-NEXT: [[TMP4:%.*]] = load i8, ptr [[ARRAYIDX11]], align 1
1145 ; BE-NEXT: [[CONV12:%.*]] = zext i8 [[TMP4]] to i64
1146 ; BE-NEXT: [[SHL13:%.*]] = shl i64 [[CONV12]], 32
1147 ; BE-NEXT: [[OR14:%.*]] = or i64 [[OR10]], [[SHL13]]
1148 ; BE-NEXT: [[ARRAYIDX15:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 5
1149 ; BE-NEXT: [[TMP5:%.*]] = load i8, ptr [[ARRAYIDX15]], align 1
1150 ; BE-NEXT: [[CONV16:%.*]] = zext i8 [[TMP5]] to i64
1151 ; BE-NEXT: [[SHL17:%.*]] = shl i64 [[CONV16]], 40
1152 ; BE-NEXT: [[OR18:%.*]] = or i64 [[OR14]], [[SHL17]]
1153 ; BE-NEXT: [[ARRAYIDX19:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 6
1154 ; BE-NEXT: [[TMP6:%.*]] = load i8, ptr [[ARRAYIDX19]], align 1
1155 ; BE-NEXT: [[CONV20:%.*]] = zext i8 [[TMP6]] to i64
1156 ; BE-NEXT: [[SHL21:%.*]] = shl i64 [[CONV20]], 48
1157 ; BE-NEXT: [[OR22:%.*]] = or i64 [[OR18]], [[SHL21]]
1158 ; BE-NEXT: [[ARRAYIDX23:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 7
1159 ; BE-NEXT: [[TMP7:%.*]] = load i8, ptr [[ARRAYIDX23]], align 1
1160 ; BE-NEXT: [[CONV24:%.*]] = zext i8 [[TMP7]] to i64
1161 ; BE-NEXT: [[SHL25:%.*]] = shl i64 [[CONV24]], 56
1162 ; BE-NEXT: [[OR26:%.*]] = or i64 [[OR22]], [[SHL25]]
1163 ; BE-NEXT: ret i64 [[OR26]]
1166 %0 = load i8, ptr %ptr, align 1
1167 %conv = zext i8 %0 to i64
1168 %arrayidx1 = getelementptr inbounds i8, ptr %ptr, i64 1
1169 %1 = load i8, ptr %arrayidx1, align 1
1170 %conv2 = zext i8 %1 to i64
1171 %shl = shl i64 %conv2, 8
1172 %or = or i64 %conv, %shl
1173 %arrayidx3 = getelementptr inbounds i8, ptr %ptr, i64 2
1174 %2 = load i8, ptr %arrayidx3, align 1
1175 %conv4 = zext i8 %2 to i64
1176 %shl5 = shl i64 %conv4, 16
1177 %or6 = or i64 %or, %shl5
1178 %arrayidx7 = getelementptr inbounds i8, ptr %ptr, i64 3
1179 %3 = load i8, ptr %arrayidx7, align 1
1180 %conv8 = zext i8 %3 to i64
1181 %shl9 = shl i64 %conv8, 24
1182 %or10 = or i64 %or6, %shl9
1183 %arrayidx11 = getelementptr inbounds i8, ptr %ptr, i64 4
1184 %4 = load i8, ptr %arrayidx11, align 1
1185 %conv12 = zext i8 %4 to i64
1186 %shl13 = shl i64 %conv12, 32
1187 %or14 = or i64 %or10, %shl13
1188 %arrayidx15 = getelementptr inbounds i8, ptr %ptr, i64 5
1189 %5 = load i8, ptr %arrayidx15, align 1
1190 %conv16 = zext i8 %5 to i64
1191 %shl17 = shl i64 %conv16, 40
1192 %or18 = or i64 %or14, %shl17
1193 %arrayidx19 = getelementptr inbounds i8, ptr %ptr, i64 6
1194 %6 = load i8, ptr %arrayidx19, align 1
1195 %conv20 = zext i8 %6 to i64
1196 %shl21 = shl i64 %conv20, 48
1197 %or22 = or i64 %or18, %shl21
1198 %arrayidx23 = getelementptr inbounds i8, ptr %ptr, i64 7
1199 %7 = load i8, ptr %arrayidx23, align 1
1200 %conv24 = zext i8 %7 to i64
1201 %shl25 = shl i64 %conv24, 56
1202 %or26 = or i64 %or22, %shl25
1206 define i32 @loadCombine_4consecutive_metadata(ptr %p, ptr %pstr) {
1207 ; LE-LABEL: @loadCombine_4consecutive_metadata(
1208 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1, !alias.scope !0
1209 ; LE-NEXT: store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
1210 ; LE-NEXT: ret i32 [[L1]]
1212 ; BE-LABEL: @loadCombine_4consecutive_metadata(
1213 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1214 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1215 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1216 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1, !alias.scope !0
1217 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1, !alias.scope !0
1218 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1, !alias.scope !0
1219 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1, !alias.scope !0
1220 ; BE-NEXT: store i32 25, ptr [[PSTR:%.*]], align 4, !noalias !0
1221 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1222 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1223 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1224 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1225 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1226 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1227 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1228 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1229 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1230 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
1231 ; BE-NEXT: ret i32 [[O3]]
1233 %p1 = getelementptr i8, ptr %p, i32 1
1234 %p2 = getelementptr i8, ptr %p, i32 2
1235 %p3 = getelementptr i8, ptr %p, i32 3
1236 %l1 = load i8, ptr %p, !alias.scope !2
1237 %l2 = load i8, ptr %p1, !alias.scope !2
1238 %l3 = load i8, ptr %p2, !alias.scope !2
1239 %l4 = load i8, ptr %p3, !alias.scope !2
1240 store i32 25, ptr %pstr, !noalias !2
1242 %e1 = zext i8 %l1 to i32
1243 %e2 = zext i8 %l2 to i32
1244 %e3 = zext i8 %l3 to i32
1245 %e4 = zext i8 %l4 to i32
1247 %s2 = shl i32 %e2, 8
1248 %s3 = shl i32 %e3, 16
1249 %s4 = shl i32 %e4, 24
1251 %o1 = or i32 %e1, %s2
1252 %o2 = or i32 %o1, %s3
1253 %o3 = or i32 %o2, %s4
1258 !1 = distinct !{!1, !0}
1262 ; CHECK: !1 = distinct !{!1, !2}
1263 ; CHECK: !2 = distinct !{!2}
1265 define i16 @loadCombine_4consecutive_4bit(ptr %p) {
1266 ; ALL-LABEL: @loadCombine_4consecutive_4bit(
1267 ; ALL-NEXT: [[P1:%.*]] = getelementptr i4, ptr [[P:%.*]], i32 1
1268 ; ALL-NEXT: [[P2:%.*]] = getelementptr i4, ptr [[P]], i32 2
1269 ; ALL-NEXT: [[P3:%.*]] = getelementptr i4, ptr [[P]], i32 3
1270 ; ALL-NEXT: [[L1:%.*]] = load i4, ptr [[P]], align 1
1271 ; ALL-NEXT: [[L2:%.*]] = load i4, ptr [[P1]], align 1
1272 ; ALL-NEXT: [[L3:%.*]] = load i4, ptr [[P2]], align 1
1273 ; ALL-NEXT: [[L4:%.*]] = load i4, ptr [[P3]], align 1
1274 ; ALL-NEXT: [[E1:%.*]] = zext i4 [[L1]] to i16
1275 ; ALL-NEXT: [[E2:%.*]] = zext i4 [[L2]] to i16
1276 ; ALL-NEXT: [[E3:%.*]] = zext i4 [[L3]] to i16
1277 ; ALL-NEXT: [[E4:%.*]] = zext i4 [[L4]] to i16
1278 ; ALL-NEXT: [[S2:%.*]] = shl i16 [[E2]], 4
1279 ; ALL-NEXT: [[S3:%.*]] = shl i16 [[E3]], 8
1280 ; ALL-NEXT: [[S4:%.*]] = shl i16 [[E4]], 12
1281 ; ALL-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1282 ; ALL-NEXT: [[O2:%.*]] = or i16 [[O1]], [[S3]]
1283 ; ALL-NEXT: [[O3:%.*]] = or i16 [[O2]], [[S4]]
1284 ; ALL-NEXT: ret i16 [[O3]]
1286 %p1 = getelementptr i4, ptr %p, i32 1
1287 %p2 = getelementptr i4, ptr %p, i32 2
1288 %p3 = getelementptr i4, ptr %p, i32 3
1289 %l1 = load i4, ptr %p
1290 %l2 = load i4, ptr %p1
1291 %l3 = load i4, ptr %p2
1292 %l4 = load i4, ptr %p3
1293 %e1 = zext i4 %l1 to i16
1294 %e2 = zext i4 %l2 to i16
1295 %e3 = zext i4 %l3 to i16
1296 %e4 = zext i4 %l4 to i16
1297 %s2 = shl i16 %e2, 4
1298 %s3 = shl i16 %e3, 8
1299 %s4 = shl i16 %e4, 12
1300 %o1 = or i16 %e1, %s2
1301 %o2 = or i16 %o1, %s3
1302 %o3 = or i16 %o2, %s4
1306 define i32 @loadCombine_4consecutive_rev(ptr %p) {
1307 ; LE-LABEL: @loadCombine_4consecutive_rev(
1308 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
1309 ; LE-NEXT: ret i32 [[L1]]
1311 ; BE-LABEL: @loadCombine_4consecutive_rev(
1312 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1313 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1314 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1315 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1316 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1317 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1318 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1319 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1320 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1321 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1322 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1323 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1324 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1325 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1326 ; BE-NEXT: [[O1:%.*]] = or i32 [[S4]], [[S3]]
1327 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S2]]
1328 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E1]]
1329 ; BE-NEXT: ret i32 [[O3]]
1331 %p1 = getelementptr i8, ptr %p, i32 1
1332 %p2 = getelementptr i8, ptr %p, i32 2
1333 %p3 = getelementptr i8, ptr %p, i32 3
1334 %l1 = load i8, ptr %p
1335 %l2 = load i8, ptr %p1
1336 %l3 = load i8, ptr %p2
1337 %l4 = load i8, ptr %p3
1339 %e1 = zext i8 %l1 to i32
1340 %e2 = zext i8 %l2 to i32
1341 %e3 = zext i8 %l3 to i32
1342 %e4 = zext i8 %l4 to i32
1344 %s2 = shl i32 %e2, 8
1345 %s3 = shl i32 %e3, 16
1346 %s4 = shl i32 %e4, 24
1348 %o1 = or i32 %s4, %s3
1349 %o2 = or i32 %o1, %s2
1350 %o3 = or i32 %o2, %e1
1354 define i64 @loadCombine_8consecutive_rev(ptr %p) {
1355 ; LE-LABEL: @loadCombine_8consecutive_rev(
1356 ; LE-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 1
1357 ; LE-NEXT: ret i64 [[L1]]
1359 ; BE-LABEL: @loadCombine_8consecutive_rev(
1360 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1361 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1362 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1363 ; BE-NEXT: [[P4:%.*]] = getelementptr i8, ptr [[P]], i32 4
1364 ; BE-NEXT: [[P5:%.*]] = getelementptr i8, ptr [[P]], i32 5
1365 ; BE-NEXT: [[P6:%.*]] = getelementptr i8, ptr [[P]], i32 6
1366 ; BE-NEXT: [[P7:%.*]] = getelementptr i8, ptr [[P]], i32 7
1367 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1368 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1369 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1370 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1371 ; BE-NEXT: [[L5:%.*]] = load i8, ptr [[P4]], align 1
1372 ; BE-NEXT: [[L6:%.*]] = load i8, ptr [[P5]], align 1
1373 ; BE-NEXT: [[L7:%.*]] = load i8, ptr [[P6]], align 1
1374 ; BE-NEXT: [[L8:%.*]] = load i8, ptr [[P7]], align 1
1375 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i64
1376 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i64
1377 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i64
1378 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i64
1379 ; BE-NEXT: [[E5:%.*]] = zext i8 [[L5]] to i64
1380 ; BE-NEXT: [[E6:%.*]] = zext i8 [[L6]] to i64
1381 ; BE-NEXT: [[E7:%.*]] = zext i8 [[L7]] to i64
1382 ; BE-NEXT: [[E8:%.*]] = zext i8 [[L8]] to i64
1383 ; BE-NEXT: [[S2:%.*]] = shl i64 [[E2]], 8
1384 ; BE-NEXT: [[S3:%.*]] = shl i64 [[E3]], 16
1385 ; BE-NEXT: [[S4:%.*]] = shl i64 [[E4]], 24
1386 ; BE-NEXT: [[S5:%.*]] = shl i64 [[E5]], 32
1387 ; BE-NEXT: [[S6:%.*]] = shl i64 [[E6]], 40
1388 ; BE-NEXT: [[S7:%.*]] = shl i64 [[E7]], 48
1389 ; BE-NEXT: [[S8:%.*]] = shl i64 [[E8]], 56
1390 ; BE-NEXT: [[O7:%.*]] = or i64 [[S8]], [[S7]]
1391 ; BE-NEXT: [[O6:%.*]] = or i64 [[O7]], [[S6]]
1392 ; BE-NEXT: [[O5:%.*]] = or i64 [[O6]], [[S5]]
1393 ; BE-NEXT: [[O4:%.*]] = or i64 [[O5]], [[S4]]
1394 ; BE-NEXT: [[O3:%.*]] = or i64 [[O4]], [[S3]]
1395 ; BE-NEXT: [[O2:%.*]] = or i64 [[O3]], [[S2]]
1396 ; BE-NEXT: [[O1:%.*]] = or i64 [[O2]], [[E1]]
1397 ; BE-NEXT: ret i64 [[O1]]
1399 %p1 = getelementptr i8, ptr %p, i32 1
1400 %p2 = getelementptr i8, ptr %p, i32 2
1401 %p3 = getelementptr i8, ptr %p, i32 3
1402 %p4 = getelementptr i8, ptr %p, i32 4
1403 %p5 = getelementptr i8, ptr %p, i32 5
1404 %p6 = getelementptr i8, ptr %p, i32 6
1405 %p7 = getelementptr i8, ptr %p, i32 7
1406 %l1 = load i8, ptr %p
1407 %l2 = load i8, ptr %p1
1408 %l3 = load i8, ptr %p2
1409 %l4 = load i8, ptr %p3
1410 %l5 = load i8, ptr %p4
1411 %l6 = load i8, ptr %p5
1412 %l7 = load i8, ptr %p6
1413 %l8 = load i8, ptr %p7
1415 %e1 = zext i8 %l1 to i64
1416 %e2 = zext i8 %l2 to i64
1417 %e3 = zext i8 %l3 to i64
1418 %e4 = zext i8 %l4 to i64
1419 %e5 = zext i8 %l5 to i64
1420 %e6 = zext i8 %l6 to i64
1421 %e7 = zext i8 %l7 to i64
1422 %e8 = zext i8 %l8 to i64
1424 %s2 = shl i64 %e2, 8
1425 %s3 = shl i64 %e3, 16
1426 %s4 = shl i64 %e4, 24
1427 %s5 = shl i64 %e5, 32
1428 %s6 = shl i64 %e6, 40
1429 %s7 = shl i64 %e7, 48
1430 %s8 = shl i64 %e8, 56
1432 %o7 = or i64 %s8, %s7
1433 %o6 = or i64 %o7, %s6
1434 %o5 = or i64 %o6, %s5
1435 %o4 = or i64 %o5, %s4
1436 %o3 = or i64 %o4, %s3
1437 %o2 = or i64 %o3, %s2
1438 %o1 = or i64 %o2, %e1
1442 define i64 @loadCombine_8consecutive_rev_BE(ptr %p) {
1443 ; LE-LABEL: @loadCombine_8consecutive_rev_BE(
1444 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1445 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1446 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1447 ; LE-NEXT: [[P4:%.*]] = getelementptr i8, ptr [[P]], i32 4
1448 ; LE-NEXT: [[P5:%.*]] = getelementptr i8, ptr [[P]], i32 5
1449 ; LE-NEXT: [[P6:%.*]] = getelementptr i8, ptr [[P]], i32 6
1450 ; LE-NEXT: [[P7:%.*]] = getelementptr i8, ptr [[P]], i32 7
1451 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1452 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1453 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1454 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1455 ; LE-NEXT: [[L5:%.*]] = load i8, ptr [[P4]], align 1
1456 ; LE-NEXT: [[L6:%.*]] = load i8, ptr [[P5]], align 1
1457 ; LE-NEXT: [[L7:%.*]] = load i8, ptr [[P6]], align 1
1458 ; LE-NEXT: [[L8:%.*]] = load i8, ptr [[P7]], align 1
1459 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i64
1460 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i64
1461 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i64
1462 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i64
1463 ; LE-NEXT: [[E5:%.*]] = zext i8 [[L5]] to i64
1464 ; LE-NEXT: [[E6:%.*]] = zext i8 [[L6]] to i64
1465 ; LE-NEXT: [[E7:%.*]] = zext i8 [[L7]] to i64
1466 ; LE-NEXT: [[E8:%.*]] = zext i8 [[L8]] to i64
1467 ; LE-NEXT: [[S1:%.*]] = shl i64 [[E1]], 56
1468 ; LE-NEXT: [[S2:%.*]] = shl i64 [[E2]], 48
1469 ; LE-NEXT: [[S3:%.*]] = shl i64 [[E3]], 40
1470 ; LE-NEXT: [[S4:%.*]] = shl i64 [[E4]], 32
1471 ; LE-NEXT: [[S5:%.*]] = shl i64 [[E5]], 24
1472 ; LE-NEXT: [[S6:%.*]] = shl i64 [[E6]], 16
1473 ; LE-NEXT: [[S7:%.*]] = shl i64 [[E7]], 8
1474 ; LE-NEXT: [[O7:%.*]] = or i64 [[E8]], [[S7]]
1475 ; LE-NEXT: [[O6:%.*]] = or i64 [[O7]], [[S6]]
1476 ; LE-NEXT: [[O5:%.*]] = or i64 [[O6]], [[S5]]
1477 ; LE-NEXT: [[O4:%.*]] = or i64 [[O5]], [[S4]]
1478 ; LE-NEXT: [[O3:%.*]] = or i64 [[O4]], [[S3]]
1479 ; LE-NEXT: [[O2:%.*]] = or i64 [[O3]], [[S2]]
1480 ; LE-NEXT: [[O1:%.*]] = or i64 [[O2]], [[S1]]
1481 ; LE-NEXT: ret i64 [[O1]]
1483 ; BE-LABEL: @loadCombine_8consecutive_rev_BE(
1484 ; BE-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 1
1485 ; BE-NEXT: ret i64 [[L1]]
1487 %p1 = getelementptr i8, ptr %p, i32 1
1488 %p2 = getelementptr i8, ptr %p, i32 2
1489 %p3 = getelementptr i8, ptr %p, i32 3
1490 %p4 = getelementptr i8, ptr %p, i32 4
1491 %p5 = getelementptr i8, ptr %p, i32 5
1492 %p6 = getelementptr i8, ptr %p, i32 6
1493 %p7 = getelementptr i8, ptr %p, i32 7
1494 %l1 = load i8, ptr %p
1495 %l2 = load i8, ptr %p1
1496 %l3 = load i8, ptr %p2
1497 %l4 = load i8, ptr %p3
1498 %l5 = load i8, ptr %p4
1499 %l6 = load i8, ptr %p5
1500 %l7 = load i8, ptr %p6
1501 %l8 = load i8, ptr %p7
1503 %e1 = zext i8 %l1 to i64
1504 %e2 = zext i8 %l2 to i64
1505 %e3 = zext i8 %l3 to i64
1506 %e4 = zext i8 %l4 to i64
1507 %e5 = zext i8 %l5 to i64
1508 %e6 = zext i8 %l6 to i64
1509 %e7 = zext i8 %l7 to i64
1510 %e8 = zext i8 %l8 to i64
1512 %s1 = shl i64 %e1, 56
1513 %s2 = shl i64 %e2, 48
1514 %s3 = shl i64 %e3, 40
1515 %s4 = shl i64 %e4, 32
1516 %s5 = shl i64 %e5, 24
1517 %s6 = shl i64 %e6, 16
1518 %s7 = shl i64 %e7, 8
1520 %o7 = or i64 %e8, %s7
1521 %o6 = or i64 %o7, %s6
1522 %o5 = or i64 %o6, %s5
1523 %o4 = or i64 %o5, %s4
1524 %o3 = or i64 %o4, %s3
1525 %o2 = or i64 %o3, %s2
1526 %o1 = or i64 %o2, %s1
1530 define i64 @eggs(ptr noundef readonly %arg) {
1532 ; LE-NEXT: [[TMP3:%.*]] = load i64, ptr [[ARG:%.*]], align 1
1533 ; LE-NEXT: ret i64 [[TMP3]]
1536 ; BE-NEXT: [[TMP3:%.*]] = load i8, ptr [[ARG:%.*]], align 1
1537 ; BE-NEXT: [[TMP4:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 1
1538 ; BE-NEXT: [[TMP5:%.*]] = load i8, ptr [[TMP4]], align 1
1539 ; BE-NEXT: [[TMP6:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 2
1540 ; BE-NEXT: [[TMP7:%.*]] = load i8, ptr [[TMP6]], align 1
1541 ; BE-NEXT: [[TMP8:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 3
1542 ; BE-NEXT: [[TMP9:%.*]] = load i8, ptr [[TMP8]], align 1
1543 ; BE-NEXT: [[TMP10:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 4
1544 ; BE-NEXT: [[TMP11:%.*]] = load i8, ptr [[TMP10]], align 1
1545 ; BE-NEXT: [[TMP12:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 5
1546 ; BE-NEXT: [[TMP13:%.*]] = load i8, ptr [[TMP12]], align 1
1547 ; BE-NEXT: [[TMP14:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 6
1548 ; BE-NEXT: [[TMP15:%.*]] = load i8, ptr [[TMP14]], align 1
1549 ; BE-NEXT: [[TMP16:%.*]] = getelementptr inbounds i8, ptr [[ARG]], i64 7
1550 ; BE-NEXT: [[TMP17:%.*]] = load i8, ptr [[TMP16]], align 1
1551 ; BE-NEXT: [[TMP18:%.*]] = zext i8 [[TMP17]] to i64
1552 ; BE-NEXT: [[TMP19:%.*]] = shl nuw i64 [[TMP18]], 56
1553 ; BE-NEXT: [[TMP20:%.*]] = zext i8 [[TMP15]] to i64
1554 ; BE-NEXT: [[TMP21:%.*]] = shl nuw nsw i64 [[TMP20]], 48
1555 ; BE-NEXT: [[TMP22:%.*]] = or i64 [[TMP19]], [[TMP21]]
1556 ; BE-NEXT: [[TMP23:%.*]] = zext i8 [[TMP13]] to i64
1557 ; BE-NEXT: [[TMP24:%.*]] = shl nuw nsw i64 [[TMP23]], 40
1558 ; BE-NEXT: [[TMP25:%.*]] = or i64 [[TMP22]], [[TMP24]]
1559 ; BE-NEXT: [[TMP26:%.*]] = zext i8 [[TMP11]] to i64
1560 ; BE-NEXT: [[TMP27:%.*]] = shl nuw nsw i64 [[TMP26]], 32
1561 ; BE-NEXT: [[TMP28:%.*]] = or i64 [[TMP25]], [[TMP27]]
1562 ; BE-NEXT: [[TMP29:%.*]] = zext i8 [[TMP9]] to i64
1563 ; BE-NEXT: [[TMP30:%.*]] = shl nuw nsw i64 [[TMP29]], 24
1564 ; BE-NEXT: [[TMP31:%.*]] = or i64 [[TMP28]], [[TMP30]]
1565 ; BE-NEXT: [[TMP32:%.*]] = zext i8 [[TMP7]] to i64
1566 ; BE-NEXT: [[TMP33:%.*]] = shl nuw nsw i64 [[TMP32]], 16
1567 ; BE-NEXT: [[TMP34:%.*]] = zext i8 [[TMP5]] to i64
1568 ; BE-NEXT: [[TMP35:%.*]] = shl nuw nsw i64 [[TMP34]], 8
1569 ; BE-NEXT: [[TMP36:%.*]] = or i64 [[TMP31]], [[TMP33]]
1570 ; BE-NEXT: [[TMP37:%.*]] = zext i8 [[TMP3]] to i64
1571 ; BE-NEXT: [[TMP38:%.*]] = or i64 [[TMP36]], [[TMP35]]
1572 ; BE-NEXT: [[TMP39:%.*]] = or i64 [[TMP38]], [[TMP37]]
1573 ; BE-NEXT: ret i64 [[TMP39]]
1575 %tmp3 = load i8, ptr %arg, align 1
1576 %tmp4 = getelementptr inbounds i8, ptr %arg, i64 1
1577 %tmp5 = load i8, ptr %tmp4, align 1
1578 %tmp6 = getelementptr inbounds i8, ptr %arg, i64 2
1579 %tmp7 = load i8, ptr %tmp6, align 1
1580 %tmp8 = getelementptr inbounds i8, ptr %arg, i64 3
1581 %tmp9 = load i8, ptr %tmp8, align 1
1582 %tmp10 = getelementptr inbounds i8, ptr %arg, i64 4
1583 %tmp11 = load i8, ptr %tmp10, align 1
1584 %tmp12 = getelementptr inbounds i8, ptr %arg, i64 5
1585 %tmp13 = load i8, ptr %tmp12, align 1
1586 %tmp14 = getelementptr inbounds i8, ptr %arg, i64 6
1587 %tmp15 = load i8, ptr %tmp14, align 1
1588 %tmp16 = getelementptr inbounds i8, ptr %arg, i64 7
1589 %tmp17 = load i8, ptr %tmp16, align 1
1590 %tmp18 = zext i8 %tmp17 to i64
1591 %tmp19 = shl nuw i64 %tmp18, 56
1592 %tmp20 = zext i8 %tmp15 to i64
1593 %tmp21 = shl nuw nsw i64 %tmp20, 48
1594 %tmp22 = or i64 %tmp19, %tmp21
1595 %tmp23 = zext i8 %tmp13 to i64
1596 %tmp24 = shl nuw nsw i64 %tmp23, 40
1597 %tmp25 = or i64 %tmp22, %tmp24
1598 %tmp26 = zext i8 %tmp11 to i64
1599 %tmp27 = shl nuw nsw i64 %tmp26, 32
1600 %tmp28 = or i64 %tmp25, %tmp27
1601 %tmp29 = zext i8 %tmp9 to i64
1602 %tmp30 = shl nuw nsw i64 %tmp29, 24
1603 %tmp31 = or i64 %tmp28, %tmp30
1604 %tmp32 = zext i8 %tmp7 to i64
1605 %tmp33 = shl nuw nsw i64 %tmp32, 16
1606 %tmp34 = zext i8 %tmp5 to i64
1607 %tmp35 = shl nuw nsw i64 %tmp34, 8
1608 %tmp36 = or i64 %tmp31, %tmp33
1609 %tmp37 = zext i8 %tmp3 to i64
1610 %tmp38 = or i64 %tmp36, %tmp35
1611 %tmp39 = or i64 %tmp38, %tmp37
1615 define i32 @loadCombine_4consecutive_mixsize1(ptr %p) {
1616 ; ALL-LABEL: @loadCombine_4consecutive_mixsize1(
1617 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1618 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 3
1619 ; ALL-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1620 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1621 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1622 ; ALL-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1623 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1624 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1625 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
1626 ; ALL-NEXT: [[S3:%.*]] = shl i32 [[E3]], 24
1627 ; ALL-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1628 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1629 ; ALL-NEXT: ret i32 [[O2]]
1631 %p1 = getelementptr i8, ptr %p, i32 2
1632 %p2 = getelementptr i8, ptr %p, i32 3
1633 %l1 = load i16, ptr %p
1634 %l2 = load i8, ptr %p1
1635 %l3 = load i8, ptr %p2
1637 %e1 = zext i16 %l1 to i32
1638 %e2 = zext i8 %l2 to i32
1639 %e3 = zext i8 %l3 to i32
1641 %s2 = shl i32 %e2, 16
1642 %s3 = shl i32 %e3, 24
1644 %o1 = or i32 %e1, %s2
1645 %o2 = or i32 %o1, %s3
1649 define i32 @loadCombine_4consecutive_mixsize1_BE(ptr %p) {
1650 ; ALL-LABEL: @loadCombine_4consecutive_mixsize1_BE(
1651 ; ALL-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1652 ; ALL-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 3
1653 ; ALL-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1654 ; ALL-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1655 ; ALL-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1656 ; ALL-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1657 ; ALL-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1658 ; ALL-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1659 ; ALL-NEXT: [[S1:%.*]] = shl i32 [[E1]], 16
1660 ; ALL-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1661 ; ALL-NEXT: [[O1:%.*]] = or i32 [[S1]], [[S2]]
1662 ; ALL-NEXT: [[O2:%.*]] = or i32 [[O1]], [[E3]]
1663 ; ALL-NEXT: ret i32 [[O2]]
1665 %p1 = getelementptr i8, ptr %p, i32 2
1666 %p2 = getelementptr i8, ptr %p, i32 3
1667 %l1 = load i16, ptr %p
1668 %l2 = load i8, ptr %p1
1669 %l3 = load i8, ptr %p2
1671 %e1 = zext i16 %l1 to i32
1672 %e2 = zext i8 %l2 to i32
1673 %e3 = zext i8 %l3 to i32
1675 %s1 = shl i32 %e1, 16
1676 %s2 = shl i32 %e2, 8
1678 %o1 = or i32 %s1, %s2
1679 %o2 = or i32 %o1, %e3
1683 define i32 @loadCombine_4consecutive_rev_mixsize1(ptr %p) {
1684 ; LE-LABEL: @loadCombine_4consecutive_rev_mixsize1(
1685 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1686 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1687 ; LE-NEXT: [[L2:%.*]] = load i16, ptr [[P2]], align 1
1688 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L2]] to i32
1689 ; LE-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 16
1690 ; LE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1691 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP2]], [[E1]]
1692 ; LE-NEXT: ret i32 [[O2]]
1694 ; BE-LABEL: @loadCombine_4consecutive_rev_mixsize1(
1695 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1696 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1697 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1698 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P2]], align 1
1699 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P3]], align 1
1700 ; BE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1701 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1702 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1703 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 16
1704 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 24
1705 ; BE-NEXT: [[O1:%.*]] = or i32 [[S3]], [[S2]]
1706 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[E1]]
1707 ; BE-NEXT: ret i32 [[O2]]
1709 %p2 = getelementptr i8, ptr %p, i32 2
1710 %p3 = getelementptr i8, ptr %p, i32 3
1711 %l1 = load i16, ptr %p
1712 %l2 = load i8, ptr %p2
1713 %l3 = load i8, ptr %p3
1715 %e1 = zext i16 %l1 to i32
1716 %e2 = zext i8 %l2 to i32
1717 %e3 = zext i8 %l3 to i32
1719 %s2 = shl i32 %e2, 16
1720 %s3 = shl i32 %e3, 24
1722 %o1 = or i32 %s3, %s2
1723 %o2 = or i32 %o1, %e1
1727 define i32 @loadCombine_4consecutive_rev_mixsize1_BE(ptr %p) {
1728 ; LE-LABEL: @loadCombine_4consecutive_rev_mixsize1_BE(
1729 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1730 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1731 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1732 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P2]], align 1
1733 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P3]], align 1
1734 ; LE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1735 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1736 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1737 ; LE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 16
1738 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1739 ; LE-NEXT: [[O1:%.*]] = or i32 [[E3]], [[S2]]
1740 ; LE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S1]]
1741 ; LE-NEXT: ret i32 [[O2]]
1743 ; BE-LABEL: @loadCombine_4consecutive_rev_mixsize1_BE(
1744 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1745 ; BE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 2
1746 ; BE-NEXT: [[L2:%.*]] = load i16, ptr [[P2]], align 1
1747 ; BE-NEXT: [[TMP1:%.*]] = zext i16 [[L2]] to i32
1748 ; BE-NEXT: [[E1:%.*]] = zext i16 [[L1]] to i32
1749 ; BE-NEXT: [[S1:%.*]] = shl i32 [[E1]], 16
1750 ; BE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S1]]
1751 ; BE-NEXT: ret i32 [[O2]]
1753 %p2 = getelementptr i8, ptr %p, i32 2
1754 %p3 = getelementptr i8, ptr %p, i32 3
1755 %l1 = load i16, ptr %p
1756 %l2 = load i8, ptr %p2
1757 %l3 = load i8, ptr %p3
1759 %e1 = zext i16 %l1 to i32
1760 %e2 = zext i8 %l2 to i32
1761 %e3 = zext i8 %l3 to i32
1763 %s1 = shl i32 %e1, 16
1764 %s2 = shl i32 %e2, 8
1766 %o1 = or i32 %e3, %s2
1767 %o2 = or i32 %o1, %s1
1771 define i32 @loadCombine_4consecutive_mixsize2(ptr %p) {
1772 ; LE-LABEL: @loadCombine_4consecutive_mixsize2(
1773 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1774 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
1775 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
1776 ; LE-NEXT: [[L3:%.*]] = load i16, ptr [[P2]], align 2
1777 ; LE-NEXT: [[E3:%.*]] = zext i16 [[L3]] to i32
1778 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1779 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
1780 ; LE-NEXT: ret i32 [[O2]]
1782 ; BE-LABEL: @loadCombine_4consecutive_mixsize2(
1783 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1784 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1785 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1786 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1787 ; BE-NEXT: [[L3:%.*]] = load i16, ptr [[P2]], align 2
1788 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1789 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1790 ; BE-NEXT: [[E3:%.*]] = zext i16 [[L3]] to i32
1791 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1792 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1793 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1794 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1795 ; BE-NEXT: ret i32 [[O2]]
1797 %p1 = getelementptr i8, ptr %p, i32 1
1798 %p2 = getelementptr i8, ptr %p, i32 2
1799 %l1 = load i8, ptr %p
1800 %l2 = load i8, ptr %p1
1801 %l3 = load i16, ptr %p2
1803 %e1 = zext i8 %l1 to i32
1804 %e2 = zext i8 %l2 to i32
1805 %e3 = zext i16 %l3 to i32
1807 %s2 = shl i32 %e2, 8
1808 %s3 = shl i32 %e3, 16
1810 %o1 = or i32 %e1, %s2
1811 %o2 = or i32 %o1, %s3
1815 define i32 @loadCombine_4consecutive_lower_index_comes_before(ptr %p) {
1816 ; LE-LABEL: @loadCombine_4consecutive_lower_index_comes_before(
1817 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P:%.*]], align 1
1818 ; LE-NEXT: ret i32 [[L1]]
1820 ; BE-LABEL: @loadCombine_4consecutive_lower_index_comes_before(
1821 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1822 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1823 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1824 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1825 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1826 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1827 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1828 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1829 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1830 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1831 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1832 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1833 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1834 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1835 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1836 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1837 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
1838 ; BE-NEXT: ret i32 [[O3]]
1840 %p1 = getelementptr i8, ptr %p, i32 1
1841 %p2 = getelementptr i8, ptr %p, i32 2
1842 %p3 = getelementptr i8, ptr %p, i32 3
1843 %l4 = load i8, ptr %p3
1844 %l3 = load i8, ptr %p2
1845 %l2 = load i8, ptr %p1
1846 %l1 = load i8, ptr %p
1848 %e1 = zext i8 %l1 to i32
1849 %e2 = zext i8 %l2 to i32
1850 %e3 = zext i8 %l3 to i32
1851 %e4 = zext i8 %l4 to i32
1853 %s2 = shl i32 %e2, 8
1854 %s3 = shl i32 %e3, 16
1855 %s4 = shl i32 %e4, 24
1857 %o1 = or i32 %e1, %s2
1858 %o2 = or i32 %o1, %s3
1859 %o3 = or i32 %o2, %s4
1863 define i16 @loadCombine_2consecutive_badinsert(ptr %p) {
1864 ; LE-LABEL: @loadCombine_2consecutive_badinsert(
1865 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1866 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
1867 ; LE-NEXT: store i8 0, ptr [[P1]], align 1
1868 ; LE-NEXT: ret i16 [[L1]]
1870 ; BE-LABEL: @loadCombine_2consecutive_badinsert(
1871 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1872 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1873 ; BE-NEXT: store i8 0, ptr [[P1]], align 1
1874 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1875 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i16
1876 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i16
1877 ; BE-NEXT: [[S2:%.*]] = shl i16 [[E2]], 8
1878 ; BE-NEXT: [[O1:%.*]] = or i16 [[E1]], [[S2]]
1879 ; BE-NEXT: ret i16 [[O1]]
1881 %p1 = getelementptr i8, ptr %p, i32 1
1882 %l2 = load i8, ptr %p1
1883 store i8 0, ptr %p1, align 1
1884 %l1 = load i8, ptr %p
1885 %e1 = zext i8 %l1 to i16
1886 %e2 = zext i8 %l2 to i16
1887 %s2 = shl i16 %e2, 8
1888 %o1 = or i16 %e1, %s2
1892 define i32 @loadCombine_4consecutive_badinsert(ptr %p) {
1893 ; LE-LABEL: @loadCombine_4consecutive_badinsert(
1894 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1895 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P]], align 1
1896 ; LE-NEXT: store i8 0, ptr [[P1]], align 1
1897 ; LE-NEXT: ret i32 [[L1]]
1899 ; BE-LABEL: @loadCombine_4consecutive_badinsert(
1900 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1901 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1902 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1903 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1904 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1905 ; BE-NEXT: store i8 0, ptr [[P1]], align 1
1906 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1907 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1908 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1909 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1910 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1911 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1912 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1913 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1914 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1915 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1916 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1917 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
1918 ; BE-NEXT: ret i32 [[O3]]
1920 %p1 = getelementptr i8, ptr %p, i32 1
1921 %p2 = getelementptr i8, ptr %p, i32 2
1922 %p3 = getelementptr i8, ptr %p, i32 3
1923 %l2 = load i8, ptr %p1
1924 %l3 = load i8, ptr %p2
1925 store i8 0, ptr %p1, align 1
1926 %l4 = load i8, ptr %p3
1927 %l1 = load i8, ptr %p
1929 %e1 = zext i8 %l1 to i32
1930 %e2 = zext i8 %l2 to i32
1931 %e3 = zext i8 %l3 to i32
1932 %e4 = zext i8 %l4 to i32
1934 %s2 = shl i32 %e2, 8
1935 %s3 = shl i32 %e3, 16
1936 %s4 = shl i32 %e4, 24
1938 %o1 = or i32 %e1, %s2
1939 %o2 = or i32 %o1, %s3
1940 %o3 = or i32 %o2, %s4
1944 define i32 @loadCombine_4consecutive_badinsert2(ptr %p) {
1945 ; LE-LABEL: @loadCombine_4consecutive_badinsert2(
1946 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
1947 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1948 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
1949 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
1950 ; LE-NEXT: store i8 0, ptr [[P3]], align 1
1951 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1952 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1953 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1954 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1955 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1956 ; LE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1957 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
1958 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
1959 ; LE-NEXT: ret i32 [[O3]]
1961 ; BE-LABEL: @loadCombine_4consecutive_badinsert2(
1962 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
1963 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
1964 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
1965 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
1966 ; BE-NEXT: store i8 0, ptr [[P3]], align 1
1967 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
1968 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
1969 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
1970 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
1971 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
1972 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
1973 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
1974 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
1975 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
1976 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
1977 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
1978 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
1979 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
1980 ; BE-NEXT: ret i32 [[O3]]
1982 %p1 = getelementptr i8, ptr %p, i32 1
1983 %p2 = getelementptr i8, ptr %p, i32 2
1984 %p3 = getelementptr i8, ptr %p, i32 3
1985 %l2 = load i8, ptr %p1
1986 store i8 0, ptr %p3, align 1
1987 %l3 = load i8, ptr %p2
1988 %l4 = load i8, ptr %p3
1989 %l1 = load i8, ptr %p
1991 %e1 = zext i8 %l1 to i32
1992 %e2 = zext i8 %l2 to i32
1993 %e3 = zext i8 %l3 to i32
1994 %e4 = zext i8 %l4 to i32
1996 %s2 = shl i32 %e2, 8
1997 %s3 = shl i32 %e3, 16
1998 %s4 = shl i32 %e4, 24
2000 %o1 = or i32 %e1, %s2
2001 %o2 = or i32 %o1, %s3
2002 %o3 = or i32 %o2, %s4
2006 define i32 @loadCombine_4consecutive_badinsert3(ptr %p) {
2007 ; LE-LABEL: @loadCombine_4consecutive_badinsert3(
2008 ; LE-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
2009 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[TMP1]], align 1
2010 ; LE-NEXT: ret i32 [[L1]]
2012 ; BE-LABEL: @loadCombine_4consecutive_badinsert3(
2013 ; BE-NEXT: [[P4:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 4
2014 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P4]], align 1
2015 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
2016 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
2017 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
2018 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P3]], align 1
2019 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
2020 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
2021 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
2022 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P2]], align 1
2023 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
2024 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
2025 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P]], i32 1
2026 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P1]], align 1
2027 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
2028 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
2029 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
2030 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
2031 ; BE-NEXT: ret i32 [[O3]]
2033 %p4 = getelementptr i8, ptr %p, i32 4
2034 %l4 = load i8, ptr %p4
2035 %e4 = zext i8 %l4 to i32
2036 %s4 = shl i32 %e4, 24
2038 %p3 = getelementptr i8, ptr %p, i32 3
2039 %l3 = load i8, ptr %p3
2040 %e3 = zext i8 %l3 to i32
2041 %s3 = shl i32 %e3, 16
2043 %p2 = getelementptr i8, ptr %p, i32 2
2044 %l2 = load i8, ptr %p2
2045 %e2 = zext i8 %l2 to i32
2046 %s2 = shl i32 %e2, 8
2048 %p1 = getelementptr i8, ptr %p, i32 1
2049 %l1 = load i8, ptr %p1
2050 %e1 = zext i8 %l1 to i32
2052 %o1 = or i32 %e1, %s2
2053 %o2 = or i32 %o1, %s3
2054 %o3 = or i32 %o2, %s4
2058 define i32 @loadCombine_4consecutive_badinsert4(ptr %p) {
2059 ; LE-LABEL: @loadCombine_4consecutive_badinsert4(
2061 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 1
2062 ; LE-NEXT: [[C1:%.*]] = load i8, ptr [[P1]], align 1
2063 ; LE-NEXT: [[CMP:%.*]] = icmp eq i8 [[C1]], 0
2064 ; LE-NEXT: br i1 [[CMP]], label [[END:%.*]], label [[BB2:%.*]]
2066 ; LE-NEXT: [[L1:%.*]] = load i32, ptr [[P1]], align 1
2067 ; LE-NEXT: br label [[END]]
2069 ; LE-NEXT: [[COND:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[L1]], [[BB2]] ]
2070 ; LE-NEXT: ret i32 [[COND]]
2072 ; BE-LABEL: @loadCombine_4consecutive_badinsert4(
2074 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 1
2075 ; BE-NEXT: [[C1:%.*]] = load i8, ptr [[P1]], align 1
2076 ; BE-NEXT: [[CMP:%.*]] = icmp eq i8 [[C1]], 0
2077 ; BE-NEXT: br i1 [[CMP]], label [[END:%.*]], label [[BB2:%.*]]
2079 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P1]], align 1
2080 ; BE-NEXT: [[C2:%.*]] = zext i8 [[L1]] to i32
2081 ; BE-NEXT: [[P4:%.*]] = getelementptr i8, ptr [[P]], i64 4
2082 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P4]], align 1
2083 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
2084 ; BE-NEXT: [[S4:%.*]] = shl nuw i32 [[E4]], 24
2085 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i64 3
2086 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P3]], align 1
2087 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
2088 ; BE-NEXT: [[S3:%.*]] = shl nuw nsw i32 [[E3]], 16
2089 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i64 2
2090 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P2]], align 1
2091 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
2092 ; BE-NEXT: [[S2:%.*]] = shl nuw nsw i32 [[E2]], 8
2093 ; BE-NEXT: [[O1:%.*]] = or i32 [[S2]], [[C2]]
2094 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
2095 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
2096 ; BE-NEXT: br label [[END]]
2098 ; BE-NEXT: [[COND:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[O3]], [[BB2]] ]
2099 ; BE-NEXT: ret i32 [[COND]]
2102 %p1 = getelementptr i8, ptr %p, i64 1
2103 %c1 = load i8, ptr %p1, align 1
2104 %cmp = icmp eq i8 %c1, 0
2105 br i1 %cmp, label %end, label %bb2
2108 %l1 = load i8, ptr %p1, align 1
2109 %c2 = zext i8 %l1 to i32
2110 %p4 = getelementptr i8, ptr %p, i64 4
2111 %l4 = load i8, ptr %p4, align 1
2112 %e4 = zext i8 %l4 to i32
2113 %s4 = shl nuw i32 %e4, 24
2114 %p3 = getelementptr i8, ptr %p, i64 3
2115 %l3 = load i8, ptr %p3, align 1
2116 %e3 = zext i8 %l3 to i32
2117 %s3 = shl nuw nsw i32 %e3, 16
2118 %p2 = getelementptr i8, ptr %p, i64 2
2119 %l2 = load i8, ptr %p2, align 1
2120 %e2 = zext i8 %l2 to i32
2121 %s2 = shl nuw nsw i32 %e2, 8
2122 %o1 = or i32 %s2, %c2
2123 %o2 = or i32 %o1, %s3
2124 %o3 = or i32 %o2, %s4
2128 %cond = phi i32 [ 0, %entry ], [ %o3, %bb2 ]
2132 define i32 @loadCombine_4consecutive_badinsert5(ptr %p) {
2133 ; LE-LABEL: @loadCombine_4consecutive_badinsert5(
2134 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
2135 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
2136 ; LE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
2137 ; LE-NEXT: store i8 0, ptr [[P2]], align 1
2138 ; LE-NEXT: [[L1:%.*]] = load i16, ptr [[P]], align 1
2139 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L1]] to i32
2140 ; LE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
2141 ; LE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
2142 ; LE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
2143 ; LE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
2144 ; LE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
2145 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP1]], [[S3]]
2146 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
2147 ; LE-NEXT: ret i32 [[O3]]
2149 ; BE-LABEL: @loadCombine_4consecutive_badinsert5(
2150 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
2151 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
2152 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
2153 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
2154 ; BE-NEXT: store i8 0, ptr [[P2]], align 1
2155 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
2156 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
2157 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
2158 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
2159 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
2160 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
2161 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
2162 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
2163 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
2164 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
2165 ; BE-NEXT: [[O1:%.*]] = or i32 [[E1]], [[S2]]
2166 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S3]]
2167 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[S4]]
2168 ; BE-NEXT: ret i32 [[O3]]
2170 %p1 = getelementptr i8, ptr %p, i32 1
2171 %p2 = getelementptr i8, ptr %p, i32 2
2172 %p3 = getelementptr i8, ptr %p, i32 3
2173 %l4 = load i8, ptr %p3
2174 store i8 0, ptr %p2, align 1
2175 %l1 = load i8, ptr %p
2176 %l2 = load i8, ptr %p1
2177 %l3 = load i8, ptr %p2
2179 %e1 = zext i8 %l1 to i32
2180 %e2 = zext i8 %l2 to i32
2181 %e3 = zext i8 %l3 to i32
2182 %e4 = zext i8 %l4 to i32
2184 %s2 = shl i32 %e2, 8
2185 %s3 = shl i32 %e3, 16
2186 %s4 = shl i32 %e4, 24
2188 %o1 = or i32 %e1, %s2
2189 %o2 = or i32 %o1, %s3
2190 %o3 = or i32 %o2, %s4
2194 define i32 @loadCombine_4consecutive_badinsert6(ptr %p) {
2195 ; LE-LABEL: @loadCombine_4consecutive_badinsert6(
2196 ; LE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
2197 ; LE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
2198 ; LE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
2199 ; LE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
2200 ; LE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
2201 ; LE-NEXT: store i8 0, ptr [[P3]], align 1
2202 ; LE-NEXT: [[L3:%.*]] = load i16, ptr [[P2]], align 1
2203 ; LE-NEXT: [[TMP1:%.*]] = zext i16 [[L3]] to i32
2204 ; LE-NEXT: [[TMP2:%.*]] = shl i32 [[TMP1]], 16
2205 ; LE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
2206 ; LE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
2207 ; LE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
2208 ; LE-NEXT: [[O2:%.*]] = or i32 [[TMP2]], [[S2]]
2209 ; LE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E1]]
2210 ; LE-NEXT: ret i32 [[O3]]
2212 ; BE-LABEL: @loadCombine_4consecutive_badinsert6(
2213 ; BE-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 1
2214 ; BE-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P]], i32 2
2215 ; BE-NEXT: [[P3:%.*]] = getelementptr i8, ptr [[P]], i32 3
2216 ; BE-NEXT: [[L1:%.*]] = load i8, ptr [[P]], align 1
2217 ; BE-NEXT: [[L2:%.*]] = load i8, ptr [[P1]], align 1
2218 ; BE-NEXT: store i8 0, ptr [[P3]], align 1
2219 ; BE-NEXT: [[L3:%.*]] = load i8, ptr [[P2]], align 1
2220 ; BE-NEXT: [[L4:%.*]] = load i8, ptr [[P3]], align 1
2221 ; BE-NEXT: [[E1:%.*]] = zext i8 [[L1]] to i32
2222 ; BE-NEXT: [[E2:%.*]] = zext i8 [[L2]] to i32
2223 ; BE-NEXT: [[E3:%.*]] = zext i8 [[L3]] to i32
2224 ; BE-NEXT: [[E4:%.*]] = zext i8 [[L4]] to i32
2225 ; BE-NEXT: [[S2:%.*]] = shl i32 [[E2]], 8
2226 ; BE-NEXT: [[S3:%.*]] = shl i32 [[E3]], 16
2227 ; BE-NEXT: [[S4:%.*]] = shl i32 [[E4]], 24
2228 ; BE-NEXT: [[O1:%.*]] = or i32 [[S3]], [[S4]]
2229 ; BE-NEXT: [[O2:%.*]] = or i32 [[O1]], [[S2]]
2230 ; BE-NEXT: [[O3:%.*]] = or i32 [[O2]], [[E1]]
2231 ; BE-NEXT: ret i32 [[O3]]
2233 %p1 = getelementptr i8, ptr %p, i32 1
2234 %p2 = getelementptr i8, ptr %p, i32 2
2235 %p3 = getelementptr i8, ptr %p, i32 3
2236 %l1 = load i8, ptr %p
2237 %l2 = load i8, ptr %p1
2238 store i8 0, ptr %p3, align 1
2239 %l3 = load i8, ptr %p2
2240 %l4 = load i8, ptr %p3
2242 %e1 = zext i8 %l1 to i32
2243 %e2 = zext i8 %l2 to i32
2244 %e3 = zext i8 %l3 to i32
2245 %e4 = zext i8 %l4 to i32
2247 %s2 = shl i32 %e2, 8
2248 %s3 = shl i32 %e3, 16
2249 %s4 = shl i32 %e4, 24
2251 %o1 = or i32 %s3, %s4
2252 %o2 = or i32 %o1, %s2
2253 %o3 = or i32 %o2, %e1
2257 define i64 @loadCombine_nonConstShift1(ptr %arg, i8 %b) {
2258 ; ALL-LABEL: @loadCombine_nonConstShift1(
2259 ; ALL-NEXT: [[G1:%.*]] = getelementptr i8, ptr [[ARG:%.*]], i64 1
2260 ; ALL-NEXT: [[LD0:%.*]] = load i8, ptr [[ARG]], align 1
2261 ; ALL-NEXT: [[LD1:%.*]] = load i8, ptr [[G1]], align 1
2262 ; ALL-NEXT: [[Z0:%.*]] = zext i8 [[LD0]] to i64
2263 ; ALL-NEXT: [[Z1:%.*]] = zext i8 [[LD1]] to i64
2264 ; ALL-NEXT: [[Z6:%.*]] = zext i8 [[B:%.*]] to i64
2265 ; ALL-NEXT: [[S0:%.*]] = shl i64 [[Z0]], [[Z6]]
2266 ; ALL-NEXT: [[S1:%.*]] = shl i64 [[Z1]], 8
2267 ; ALL-NEXT: [[O7:%.*]] = or i64 [[S0]], [[S1]]
2268 ; ALL-NEXT: ret i64 [[O7]]
2270 %g1 = getelementptr i8, ptr %arg, i64 1
2271 %ld0 = load i8, ptr %arg, align 1
2272 %ld1 = load i8, ptr %g1, align 1
2273 %z0 = zext i8 %ld0 to i64
2274 %z1 = zext i8 %ld1 to i64
2275 %z6 = zext i8 %b to i64
2276 %s0 = shl i64 %z0, %z6
2277 %s1 = shl i64 %z1, 8
2278 %o7 = or i64 %s0, %s1
2282 define i64 @loadCombine_nonConstShift2(ptr %arg, i8 %b) {
2283 ; ALL-LABEL: @loadCombine_nonConstShift2(
2284 ; ALL-NEXT: [[G1:%.*]] = getelementptr i8, ptr [[ARG:%.*]], i64 1
2285 ; ALL-NEXT: [[LD0:%.*]] = load i8, ptr [[ARG]], align 1
2286 ; ALL-NEXT: [[LD1:%.*]] = load i8, ptr [[G1]], align 1
2287 ; ALL-NEXT: [[Z0:%.*]] = zext i8 [[LD0]] to i64
2288 ; ALL-NEXT: [[Z1:%.*]] = zext i8 [[LD1]] to i64
2289 ; ALL-NEXT: [[Z6:%.*]] = zext i8 [[B:%.*]] to i64
2290 ; ALL-NEXT: [[S0:%.*]] = shl i64 [[Z0]], [[Z6]]
2291 ; ALL-NEXT: [[S1:%.*]] = shl i64 [[Z1]], 8
2292 ; ALL-NEXT: [[O7:%.*]] = or i64 [[S1]], [[S0]]
2293 ; ALL-NEXT: ret i64 [[O7]]
2295 %g1 = getelementptr i8, ptr %arg, i64 1
2296 %ld0 = load i8, ptr %arg, align 1
2297 %ld1 = load i8, ptr %g1, align 1
2298 %z0 = zext i8 %ld0 to i64
2299 %z1 = zext i8 %ld1 to i64
2300 %z6 = zext i8 %b to i64
2301 %s0 = shl i64 %z0, %z6
2302 %s1 = shl i64 %z1, 8
2303 %o7 = or i64 %s1, %s0
2307 define void @nested_gep(ptr %p, ptr %dest) {
2308 ; LE-LABEL: @nested_gep(
2309 ; LE-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
2310 ; LE-NEXT: [[LD2:%.*]] = load i64, ptr [[TMP1]], align 4
2311 ; LE-NEXT: [[TRUNC:%.*]] = trunc i64 [[LD2]] to i32
2312 ; LE-NEXT: store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
2315 ; BE-LABEL: @nested_gep(
2316 ; BE-NEXT: [[GEP1:%.*]] = getelementptr inbounds i8, ptr [[P:%.*]], i64 72
2317 ; BE-NEXT: [[LD1:%.*]] = load i32, ptr [[GEP1]], align 4
2318 ; BE-NEXT: [[LD1_ZEXT:%.*]] = zext i32 [[LD1]] to i64
2319 ; BE-NEXT: [[LD1_SHL:%.*]] = shl nuw i64 [[LD1_ZEXT]], 32
2320 ; BE-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 64
2321 ; BE-NEXT: [[FINAL_PTR:%.*]] = getelementptr inbounds i8, ptr [[GEP2]], i64 4
2322 ; BE-NEXT: [[LD2:%.*]] = load i32, ptr [[FINAL_PTR]], align 4
2323 ; BE-NEXT: [[LD2_ZEXT:%.*]] = zext i32 [[LD2]] to i64
2324 ; BE-NEXT: [[OR:%.*]] = or i64 [[LD1_SHL]], [[LD2_ZEXT]]
2325 ; BE-NEXT: [[ADD:%.*]] = add i64 [[OR]], 0
2326 ; BE-NEXT: [[TRUNC:%.*]] = trunc i64 [[ADD]] to i32
2327 ; BE-NEXT: store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
2330 %gep1 = getelementptr inbounds i8, ptr %p, i64 72
2331 %ld1 = load i32, ptr %gep1, align 4
2332 %ld1_zext = zext i32 %ld1 to i64
2333 %ld1_shl = shl nuw i64 %ld1_zext, 32
2334 %gep2 = getelementptr inbounds i8, ptr %p, i64 64
2335 ; Don't move final_ptr before gep2
2336 %final_ptr = getelementptr inbounds i8, ptr %gep2, i64 4
2337 %ld2 = load i32, ptr %final_ptr, align 4
2338 %ld2_zext = zext i32 %ld2 to i64
2339 %or = or i64 %ld1_shl, %ld2_zext
2340 %add = add i64 %or, 0
2341 %trunc = trunc i64 %add to i32
2342 store i32 %trunc, ptr %dest, align 4
2347 define void @bitcast_gep(ptr %p, ptr %dest) {
2348 ; LE-LABEL: @bitcast_gep(
2349 ; LE-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 68
2350 ; LE-NEXT: [[LD2:%.*]] = load i64, ptr [[TMP1]], align 4
2351 ; LE-NEXT: [[TRUNC:%.*]] = trunc i64 [[LD2]] to i32
2352 ; LE-NEXT: store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
2355 ; BE-LABEL: @bitcast_gep(
2356 ; BE-NEXT: [[GEP1:%.*]] = getelementptr inbounds i8, ptr [[P:%.*]], i64 72
2357 ; BE-NEXT: [[LD1:%.*]] = load i32, ptr [[GEP1]], align 4
2358 ; BE-NEXT: [[LD1_ZEXT:%.*]] = zext i32 [[LD1]] to i64
2359 ; BE-NEXT: [[LD1_SHL:%.*]] = shl nuw i64 [[LD1_ZEXT]], 32
2360 ; BE-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 68
2361 ; BE-NEXT: [[FINAL_PTR:%.*]] = bitcast ptr [[GEP2]] to ptr
2362 ; BE-NEXT: [[LD2:%.*]] = load i32, ptr [[FINAL_PTR]], align 4
2363 ; BE-NEXT: [[LD2_ZEXT:%.*]] = zext i32 [[LD2]] to i64
2364 ; BE-NEXT: [[OR:%.*]] = or i64 [[LD1_SHL]], [[LD2_ZEXT]]
2365 ; BE-NEXT: [[ADD:%.*]] = add i64 [[OR]], 0
2366 ; BE-NEXT: [[TRUNC:%.*]] = trunc i64 [[ADD]] to i32
2367 ; BE-NEXT: store i32 [[TRUNC]], ptr [[DEST:%.*]], align 4
2370 %gep1 = getelementptr inbounds i8, ptr %p, i64 72
2371 %ld1 = load i32, ptr %gep1, align 4
2372 %ld1_zext = zext i32 %ld1 to i64
2373 %ld1_shl = shl nuw i64 %ld1_zext, 32
2374 %gep2 = getelementptr inbounds i8, ptr %p, i64 68
2375 ; Don't move final_ptr before gep2
2376 %final_ptr = bitcast ptr %gep2 to ptr
2377 %ld2 = load i32, ptr %final_ptr, align 4
2378 %ld2_zext = zext i32 %ld2 to i64
2379 %or = or i64 %ld1_shl, %ld2_zext
2380 %add = add i64 %or, 0
2381 %trunc = trunc i64 %add to i32
2382 store i32 %trunc, ptr %dest, align 4