1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 < %s | FileCheck %s
5 ; unsigned long test_no_prep(char *p, int count) {
6 ; unsigned long i=0, res=0;
11 ; for (; i < count ; i++) {
12 ; unsigned long x1 = *(unsigned long *)(p + i + DISP1);
13 ; unsigned long x2 = *(unsigned long *)(p + i + DISP2);
14 ; unsigned long x3 = *(unsigned long *)(p + i + DISP3);
15 ; unsigned long x4 = *(unsigned long *)(p + i + DISP4);
21 define i64 @test_no_prep(ptr %arg, i32 signext %arg1) {
22 ; CHECK-LABEL: test_no_prep:
23 ; CHECK: # %bb.0: # %bb
24 ; CHECK-NEXT: cmplwi r4, 0
25 ; CHECK-NEXT: beq cr0, .LBB0_4
26 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
27 ; CHECK-NEXT: cmpldi r4, 1
28 ; CHECK-NEXT: li r5, 1
29 ; CHECK-NEXT: addi r3, r3, 4004
30 ; CHECK-NEXT: li r6, -3
31 ; CHECK-NEXT: li r7, -2
32 ; CHECK-NEXT: li r8, -1
33 ; CHECK-NEXT: iselgt r5, r4, r5
34 ; CHECK-NEXT: mtctr r5
35 ; CHECK-NEXT: li r5, 0
36 ; CHECK-NEXT: .p2align 4
37 ; CHECK-NEXT: .LBB0_2: # %bb3
39 ; CHECK-NEXT: ldx r9, r3, r6
40 ; CHECK-NEXT: ldx r10, r3, r7
41 ; CHECK-NEXT: ldx r11, r3, r8
42 ; CHECK-NEXT: ld r12, 0(r3)
43 ; CHECK-NEXT: addi r3, r3, 1
44 ; CHECK-NEXT: mulld r9, r10, r9
45 ; CHECK-NEXT: mulld r9, r9, r11
46 ; CHECK-NEXT: maddld r5, r9, r12, r5
47 ; CHECK-NEXT: bdnz .LBB0_2
48 ; CHECK-NEXT: # %bb.3: # %bb25
49 ; CHECK-NEXT: add r3, r5, r4
51 ; CHECK-NEXT: .LBB0_4:
52 ; CHECK-NEXT: addi r3, r4, 0
55 %i = sext i32 %arg1 to i64
56 %i2 = icmp eq i32 %arg1, 0
57 br i1 %i2, label %bb25, label %bb3
59 bb3: ; preds = %bb3, %bb
60 %i4 = phi i64 [ %i23, %bb3 ], [ 0, %bb ]
61 %i5 = phi i64 [ %i22, %bb3 ], [ 0, %bb ]
62 %i6 = getelementptr inbounds i8, ptr %arg, i64 %i4
63 %i7 = getelementptr inbounds i8, ptr %i6, i64 4001
64 %i9 = load i64, ptr %i7, align 8
65 %i10 = getelementptr inbounds i8, ptr %i6, i64 4002
66 %i12 = load i64, ptr %i10, align 8
67 %i13 = getelementptr inbounds i8, ptr %i6, i64 4003
68 %i15 = load i64, ptr %i13, align 8
69 %i16 = getelementptr inbounds i8, ptr %i6, i64 4004
70 %i18 = load i64, ptr %i16, align 8
71 %i19 = mul i64 %i12, %i9
72 %i20 = mul i64 %i19, %i15
73 %i21 = mul i64 %i20, %i18
74 %i22 = add i64 %i21, %i5
75 %i23 = add nuw i64 %i4, 1
76 %i24 = icmp ult i64 %i23, %i
77 br i1 %i24, label %bb3, label %bb25
79 bb25: ; preds = %bb3, %bb
80 %i26 = phi i64 [ 0, %bb ], [ %i22, %bb3 ]
81 %i27 = add i64 %i26, %i
86 ; unsigned long test_ds_prep(char *p, int count) {
87 ; unsigned long i=0, res=0;
92 ; for (; i < count ; i++) {
93 ; unsigned long x1 = *(unsigned long *)(p + i + DISP1);
94 ; unsigned long x2 = *(unsigned long *)(p + i + DISP2);
95 ; unsigned long x3 = *(unsigned long *)(p + i + DISP3);
96 ; unsigned long x4 = *(unsigned long *)(p + i + DISP4);
102 define i64 @test_ds_prep(ptr %arg, i32 signext %arg1) {
103 ; CHECK-LABEL: test_ds_prep:
104 ; CHECK: # %bb.0: # %bb
105 ; CHECK-NEXT: cmplwi r4, 0
106 ; CHECK-NEXT: beq cr0, .LBB1_4
107 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
108 ; CHECK-NEXT: cmpldi r4, 1
109 ; CHECK-NEXT: li r5, 1
110 ; CHECK-NEXT: addi r6, r3, 4002
111 ; CHECK-NEXT: li r7, -1
112 ; CHECK-NEXT: iselgt r3, r4, r5
113 ; CHECK-NEXT: mtctr r3
114 ; CHECK-NEXT: li r3, 0
115 ; CHECK-NEXT: .p2align 4
116 ; CHECK-NEXT: .LBB1_2: # %bb3
118 ; CHECK-NEXT: ldx r8, r6, r7
119 ; CHECK-NEXT: ld r9, 0(r6)
120 ; CHECK-NEXT: ldx r10, r6, r5
121 ; CHECK-NEXT: ld r11, 4(r6)
122 ; CHECK-NEXT: addi r6, r6, 1
123 ; CHECK-NEXT: mulld r8, r9, r8
124 ; CHECK-NEXT: mulld r8, r8, r10
125 ; CHECK-NEXT: maddld r3, r8, r11, r3
126 ; CHECK-NEXT: bdnz .LBB1_2
127 ; CHECK-NEXT: # %bb.3: # %bb25
128 ; CHECK-NEXT: add r3, r3, r4
130 ; CHECK-NEXT: .LBB1_4:
131 ; CHECK-NEXT: addi r3, r4, 0
134 %i = sext i32 %arg1 to i64
135 %i2 = icmp eq i32 %arg1, 0
136 br i1 %i2, label %bb25, label %bb3
138 bb3: ; preds = %bb3, %bb
139 %i4 = phi i64 [ %i23, %bb3 ], [ 0, %bb ]
140 %i5 = phi i64 [ %i22, %bb3 ], [ 0, %bb ]
141 %i6 = getelementptr inbounds i8, ptr %arg, i64 %i4
142 %i7 = getelementptr inbounds i8, ptr %i6, i64 4001
143 %i9 = load i64, ptr %i7, align 8
144 %i10 = getelementptr inbounds i8, ptr %i6, i64 4002
145 %i12 = load i64, ptr %i10, align 8
146 %i13 = getelementptr inbounds i8, ptr %i6, i64 4003
147 %i15 = load i64, ptr %i13, align 8
148 %i16 = getelementptr inbounds i8, ptr %i6, i64 4006
149 %i18 = load i64, ptr %i16, align 8
150 %i19 = mul i64 %i12, %i9
151 %i20 = mul i64 %i19, %i15
152 %i21 = mul i64 %i20, %i18
153 %i22 = add i64 %i21, %i5
154 %i23 = add nuw i64 %i4, 1
155 %i24 = icmp ult i64 %i23, %i
156 br i1 %i24, label %bb3, label %bb25
158 bb25: ; preds = %bb3, %bb
159 %i26 = phi i64 [ 0, %bb ], [ %i22, %bb3 ]
160 %i27 = add i64 %i26, %i
164 ; test_max_number_reminder:
165 ; unsigned long test_max_number_reminder(char *p, int count) {
166 ; unsigned long i=0, res=0;
176 ; for (; i < count ; i++) {
177 ; unsigned long x1 = *(unsigned long *)(p + i + DISP1);
178 ; unsigned long x2 = *(unsigned long *)(p + i + DISP2);
179 ; unsigned long x3 = *(unsigned long *)(p + i + DISP3);
180 ; unsigned long x4 = *(unsigned long *)(p + i + DISP4);
181 ; unsigned long x5 = *(unsigned long *)(p + i + DISP5);
182 ; unsigned long x6 = *(unsigned long *)(p + i + DISP6);
183 ; unsigned long x7 = *(unsigned long *)(p + i + DISP7);
184 ; unsigned long x8 = *(unsigned long *)(p + i + DISP8);
185 ; unsigned long x9 = *(unsigned long *)(p + i + DISP9);
186 ; res += x1*x2*x3*x4*x5*x6*x7*x8*x9;
188 ; return res + count;
191 define i64 @test_max_number_reminder(ptr %arg, i32 signext %arg1) {
192 ; CHECK-LABEL: test_max_number_reminder:
193 ; CHECK: # %bb.0: # %bb
194 ; CHECK-NEXT: cmplwi r4, 0
195 ; CHECK-NEXT: beq cr0, .LBB2_4
196 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
197 ; CHECK-NEXT: cmpldi r4, 1
198 ; CHECK-NEXT: li r5, 1
199 ; CHECK-NEXT: addi r9, r3, 4002
200 ; CHECK-NEXT: std r25, -56(r1) # 8-byte Folded Spill
201 ; CHECK-NEXT: li r6, -1
202 ; CHECK-NEXT: std r26, -48(r1) # 8-byte Folded Spill
203 ; CHECK-NEXT: li r7, 3
204 ; CHECK-NEXT: li r8, 5
205 ; CHECK-NEXT: li r10, 9
206 ; CHECK-NEXT: std r27, -40(r1) # 8-byte Folded Spill
207 ; CHECK-NEXT: std r28, -32(r1) # 8-byte Folded Spill
208 ; CHECK-NEXT: std r29, -24(r1) # 8-byte Folded Spill
209 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
210 ; CHECK-NEXT: iselgt r3, r4, r5
211 ; CHECK-NEXT: mtctr r3
212 ; CHECK-NEXT: li r3, 0
213 ; CHECK-NEXT: .p2align 4
214 ; CHECK-NEXT: .LBB2_2: # %bb3
216 ; CHECK-NEXT: ldx r11, r9, r6
217 ; CHECK-NEXT: ld r12, 0(r9)
218 ; CHECK-NEXT: ldx r0, r9, r5
219 ; CHECK-NEXT: ldx r30, r9, r7
220 ; CHECK-NEXT: mulld r11, r12, r11
221 ; CHECK-NEXT: ld r29, 4(r9)
222 ; CHECK-NEXT: ldx r28, r9, r8
223 ; CHECK-NEXT: ld r27, 12(r9)
224 ; CHECK-NEXT: ld r26, 8(r9)
225 ; CHECK-NEXT: ldx r25, r9, r10
226 ; CHECK-NEXT: addi r9, r9, 1
227 ; CHECK-NEXT: mulld r11, r11, r0
228 ; CHECK-NEXT: mulld r11, r11, r30
229 ; CHECK-NEXT: mulld r11, r11, r29
230 ; CHECK-NEXT: mulld r11, r11, r28
231 ; CHECK-NEXT: mulld r11, r11, r27
232 ; CHECK-NEXT: mulld r11, r11, r26
233 ; CHECK-NEXT: maddld r3, r11, r25, r3
234 ; CHECK-NEXT: bdnz .LBB2_2
235 ; CHECK-NEXT: # %bb.3:
236 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
237 ; CHECK-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
238 ; CHECK-NEXT: ld r28, -32(r1) # 8-byte Folded Reload
239 ; CHECK-NEXT: ld r27, -40(r1) # 8-byte Folded Reload
240 ; CHECK-NEXT: add r3, r3, r4
241 ; CHECK-NEXT: ld r26, -48(r1) # 8-byte Folded Reload
242 ; CHECK-NEXT: ld r25, -56(r1) # 8-byte Folded Reload
244 ; CHECK-NEXT: .LBB2_4:
245 ; CHECK-NEXT: addi r3, r4, 0
248 %i = sext i32 %arg1 to i64
249 %i2 = icmp eq i32 %arg1, 0
250 br i1 %i2, label %bb45, label %bb3
252 bb3: ; preds = %bb3, %bb
253 %i4 = phi i64 [ %i43, %bb3 ], [ 0, %bb ]
254 %i5 = phi i64 [ %i42, %bb3 ], [ 0, %bb ]
255 %i6 = getelementptr inbounds i8, ptr %arg, i64 %i4
256 %i7 = getelementptr inbounds i8, ptr %i6, i64 4001
257 %i9 = load i64, ptr %i7, align 8
258 %i10 = getelementptr inbounds i8, ptr %i6, i64 4002
259 %i12 = load i64, ptr %i10, align 8
260 %i13 = getelementptr inbounds i8, ptr %i6, i64 4003
261 %i15 = load i64, ptr %i13, align 8
262 %i16 = getelementptr inbounds i8, ptr %i6, i64 4005
263 %i18 = load i64, ptr %i16, align 8
264 %i19 = getelementptr inbounds i8, ptr %i6, i64 4006
265 %i21 = load i64, ptr %i19, align 8
266 %i22 = getelementptr inbounds i8, ptr %i6, i64 4007
267 %i24 = load i64, ptr %i22, align 8
268 %i25 = getelementptr inbounds i8, ptr %i6, i64 4014
269 %i27 = load i64, ptr %i25, align 8
270 %i28 = getelementptr inbounds i8, ptr %i6, i64 4010
271 %i30 = load i64, ptr %i28, align 8
272 %i31 = getelementptr inbounds i8, ptr %i6, i64 4011
273 %i33 = load i64, ptr %i31, align 8
274 %i34 = mul i64 %i12, %i9
275 %i35 = mul i64 %i34, %i15
276 %i36 = mul i64 %i35, %i18
277 %i37 = mul i64 %i36, %i21
278 %i38 = mul i64 %i37, %i24
279 %i39 = mul i64 %i38, %i27
280 %i40 = mul i64 %i39, %i30
281 %i41 = mul i64 %i40, %i33
282 %i42 = add i64 %i41, %i5
283 %i43 = add nuw i64 %i4, 1
284 %i44 = icmp ult i64 %i43, %i
285 br i1 %i44, label %bb3, label %bb45
287 bb45: ; preds = %bb3, %bb
288 %i46 = phi i64 [ 0, %bb ], [ %i42, %bb3 ]
289 %i47 = add i64 %i46, %i
293 ; test_update_ds_prep_interact:
294 ; unsigned long test_update_ds_prep_interact(char *p, int count) {
295 ; unsigned long i=0, res=0;
300 ; for (; i < count ; i++) {
301 ; unsigned long x1 = *(unsigned long *)(p + 4 * i + DISP1);
302 ; unsigned long x2 = *(unsigned long *)(p + 4 * i + DISP2);
303 ; unsigned long x3 = *(unsigned long *)(p + 4 * i + DISP3);
304 ; unsigned long x4 = *(unsigned long *)(p + 4 * i + DISP4);
305 ; res += x1*x2*x3*x4;
307 ; return res + count;
310 define dso_local i64 @test_update_ds_prep_interact(ptr %arg, i32 signext %arg1) {
311 ; CHECK-LABEL: test_update_ds_prep_interact:
312 ; CHECK: # %bb.0: # %bb
313 ; CHECK-NEXT: cmplwi r4, 0
314 ; CHECK-NEXT: beq cr0, .LBB3_4
315 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
316 ; CHECK-NEXT: cmpldi r4, 1
317 ; CHECK-NEXT: li r6, 1
318 ; CHECK-NEXT: addi r3, r3, 3998
319 ; CHECK-NEXT: li r7, -1
320 ; CHECK-NEXT: iselgt r5, r4, r6
321 ; CHECK-NEXT: mtctr r5
322 ; CHECK-NEXT: li r5, 0
323 ; CHECK-NEXT: .p2align 5
324 ; CHECK-NEXT: .LBB3_2: # %bb3
326 ; CHECK-NEXT: ldu r8, 4(r3)
327 ; CHECK-NEXT: ldx r9, r3, r7
328 ; CHECK-NEXT: ldx r10, r3, r6
329 ; CHECK-NEXT: ld r11, 4(r3)
330 ; CHECK-NEXT: mulld r8, r8, r9
331 ; CHECK-NEXT: mulld r8, r8, r10
332 ; CHECK-NEXT: maddld r5, r8, r11, r5
333 ; CHECK-NEXT: bdnz .LBB3_2
334 ; CHECK-NEXT: # %bb.3: # %bb26
335 ; CHECK-NEXT: add r3, r5, r4
337 ; CHECK-NEXT: .LBB3_4:
338 ; CHECK-NEXT: addi r3, r4, 0
341 %i = sext i32 %arg1 to i64
342 %i2 = icmp eq i32 %arg1, 0
343 br i1 %i2, label %bb26, label %bb3
345 bb3: ; preds = %bb3, %bb
346 %i4 = phi i64 [ %i24, %bb3 ], [ 0, %bb ]
347 %i5 = phi i64 [ %i23, %bb3 ], [ 0, %bb ]
349 %i7 = getelementptr inbounds i8, ptr %arg, i64 %i6
350 %i8 = getelementptr inbounds i8, ptr %i7, i64 4001
351 %i10 = load i64, ptr %i8, align 8
352 %i11 = getelementptr inbounds i8, ptr %i7, i64 4002
353 %i13 = load i64, ptr %i11, align 8
354 %i14 = getelementptr inbounds i8, ptr %i7, i64 4003
355 %i16 = load i64, ptr %i14, align 8
356 %i17 = getelementptr inbounds i8, ptr %i7, i64 4006
357 %i19 = load i64, ptr %i17, align 8
358 %i20 = mul i64 %i13, %i10
359 %i21 = mul i64 %i20, %i16
360 %i22 = mul i64 %i21, %i19
361 %i23 = add i64 %i22, %i5
362 %i24 = add nuw i64 %i4, 1
363 %i25 = icmp ult i64 %i24, %i
364 br i1 %i25, label %bb3, label %bb26
366 bb26: ; preds = %bb3, %bb
367 %i27 = phi i64 [ 0, %bb ], [ %i23, %bb3 ]
368 %i28 = add i64 %i27, %i
372 ; test_update_ds_prep_nointeract:
373 ; unsigned long test_update_ds_prep_nointeract(char *p, int count) {
374 ; unsigned long i=0, res=0;
379 ; for (; i < count ; i++) {
380 ; char x1 = *(p + i + DISP1);
381 ; unsigned long x2 = *(unsigned long *)(p + i + DISP2);
382 ; unsigned long x3 = *(unsigned long *)(p + i + DISP3);
383 ; unsigned long x4 = *(unsigned long *)(p + i + DISP4);
384 ; res += (unsigned long)x1*x2*x3*x4;
386 ; return res + count;
389 define i64 @test_update_ds_prep_nointeract(ptr %arg, i32 signext %arg1) {
390 ; CHECK-LABEL: test_update_ds_prep_nointeract:
391 ; CHECK: # %bb.0: # %bb
392 ; CHECK-NEXT: cmplwi r4, 0
393 ; CHECK-NEXT: beq cr0, .LBB4_4
394 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
395 ; CHECK-NEXT: cmpldi r4, 1
396 ; CHECK-NEXT: li r6, 1
397 ; CHECK-NEXT: addi r5, r3, 4000
398 ; CHECK-NEXT: addi r3, r3, 4003
399 ; CHECK-NEXT: li r7, -1
400 ; CHECK-NEXT: iselgt r6, r4, r6
401 ; CHECK-NEXT: mtctr r6
402 ; CHECK-NEXT: li r6, 0
403 ; CHECK-NEXT: .p2align 4
404 ; CHECK-NEXT: .LBB4_2: # %bb3
406 ; CHECK-NEXT: lbzu r8, 1(r5)
407 ; CHECK-NEXT: ldx r9, r3, r7
408 ; CHECK-NEXT: ld r10, 0(r3)
409 ; CHECK-NEXT: ld r11, 4(r3)
410 ; CHECK-NEXT: addi r3, r3, 1
411 ; CHECK-NEXT: mulld r8, r9, r8
412 ; CHECK-NEXT: mulld r8, r8, r10
413 ; CHECK-NEXT: maddld r6, r8, r11, r6
414 ; CHECK-NEXT: bdnz .LBB4_2
415 ; CHECK-NEXT: # %bb.3: # %bb25
416 ; CHECK-NEXT: add r3, r6, r4
418 ; CHECK-NEXT: .LBB4_4:
419 ; CHECK-NEXT: addi r3, r4, 0
422 %i = sext i32 %arg1 to i64
423 %i2 = icmp eq i32 %arg1, 0
424 br i1 %i2, label %bb25, label %bb3
426 bb3: ; preds = %bb3, %bb
427 %i4 = phi i64 [ %i23, %bb3 ], [ 0, %bb ]
428 %i5 = phi i64 [ %i22, %bb3 ], [ 0, %bb ]
429 %i6 = getelementptr inbounds i8, ptr %arg, i64 %i4
430 %i7 = getelementptr inbounds i8, ptr %i6, i64 4001
431 %i8 = load i8, ptr %i7, align 1
432 %i9 = getelementptr inbounds i8, ptr %i6, i64 4002
433 %i11 = load i64, ptr %i9, align 8
434 %i12 = getelementptr inbounds i8, ptr %i6, i64 4003
435 %i14 = load i64, ptr %i12, align 8
436 %i15 = getelementptr inbounds i8, ptr %i6, i64 4007
437 %i17 = load i64, ptr %i15, align 8
438 %i18 = zext i8 %i8 to i64
439 %i19 = mul i64 %i11, %i18
440 %i20 = mul i64 %i19, %i14
441 %i21 = mul i64 %i20, %i17
442 %i22 = add i64 %i21, %i5
443 %i23 = add nuw i64 %i4, 1
444 %i24 = icmp ult i64 %i23, %i
445 br i1 %i24, label %bb3, label %bb25
447 bb25: ; preds = %bb3, %bb
448 %i26 = phi i64 [ 0, %bb ], [ %i22, %bb3 ]
449 %i27 = add i64 %i26, %i
453 ; test_ds_multiple_chains:
454 ; unsigned long test_ds_multiple_chains(char *p, char *q, int count) {
455 ; unsigned long i=0, res=0;
460 ; for (; i < count ; i++) {
461 ; unsigned long x1 = *(unsigned long *)(p + i + DISP1);
462 ; unsigned long x2 = *(unsigned long *)(p + i + DISP2);
463 ; unsigned long x3 = *(unsigned long *)(p + i + DISP3);
464 ; unsigned long x4 = *(unsigned long *)(p + i + DISP4);
465 ; unsigned long x5 = *(unsigned long *)(q + i + DISP1);
466 ; unsigned long x6 = *(unsigned long *)(q + i + DISP2);
467 ; unsigned long x7 = *(unsigned long *)(q + i + DISP3);
468 ; unsigned long x8 = *(unsigned long *)(q + i + DISP4);
469 ; res += x1*x2*x3*x4*x5*x6*x7*x8;
471 ; return res + count;
474 define dso_local i64 @test_ds_multiple_chains(ptr %arg, ptr %arg1, i32 signext %arg2) {
475 ; CHECK-LABEL: test_ds_multiple_chains:
476 ; CHECK: # %bb.0: # %bb
477 ; CHECK-NEXT: cmplwi r5, 0
478 ; CHECK-NEXT: beq cr0, .LBB5_4
479 ; CHECK-NEXT: # %bb.1: # %bb4.preheader
480 ; CHECK-NEXT: cmpldi r5, 1
481 ; CHECK-NEXT: li r6, 1
482 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
483 ; CHECK-NEXT: addi r3, r3, 4001
484 ; CHECK-NEXT: addi r4, r4, 4001
485 ; CHECK-NEXT: li r7, 9
486 ; CHECK-NEXT: iselgt r6, r5, r6
487 ; CHECK-NEXT: mtctr r6
488 ; CHECK-NEXT: li r6, 0
489 ; CHECK-NEXT: .p2align 4
490 ; CHECK-NEXT: .LBB5_2: # %bb4
492 ; CHECK-NEXT: ld r8, 0(r3)
493 ; CHECK-NEXT: ldx r9, r3, r7
494 ; CHECK-NEXT: ld r10, 4(r3)
495 ; CHECK-NEXT: ld r11, 8(r3)
496 ; CHECK-NEXT: addi r3, r3, 1
497 ; CHECK-NEXT: mulld r8, r9, r8
498 ; CHECK-NEXT: ld r12, 0(r4)
499 ; CHECK-NEXT: ldx r0, r4, r7
500 ; CHECK-NEXT: ld r30, 4(r4)
501 ; CHECK-NEXT: ld r9, 8(r4)
502 ; CHECK-NEXT: addi r4, r4, 1
503 ; CHECK-NEXT: mulld r8, r8, r10
504 ; CHECK-NEXT: mulld r8, r8, r11
505 ; CHECK-NEXT: mulld r8, r8, r12
506 ; CHECK-NEXT: mulld r8, r8, r0
507 ; CHECK-NEXT: mulld r8, r8, r30
508 ; CHECK-NEXT: maddld r6, r8, r9, r6
509 ; CHECK-NEXT: bdnz .LBB5_2
510 ; CHECK-NEXT: # %bb.3:
511 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
512 ; CHECK-NEXT: add r3, r6, r5
514 ; CHECK-NEXT: .LBB5_4:
515 ; CHECK-NEXT: addi r3, r5, 0
518 %i = sext i32 %arg2 to i64
519 %i3 = icmp eq i32 %arg2, 0
520 br i1 %i3, label %bb43, label %bb4
522 bb4: ; preds = %bb4, %bb
523 %i5 = phi i64 [ %i41, %bb4 ], [ 0, %bb ]
524 %i6 = phi i64 [ %i40, %bb4 ], [ 0, %bb ]
525 %i7 = getelementptr inbounds i8, ptr %arg, i64 %i5
526 %i8 = getelementptr inbounds i8, ptr %i7, i64 4001
527 %i10 = load i64, ptr %i8, align 8
528 %i11 = getelementptr inbounds i8, ptr %i7, i64 4010
529 %i13 = load i64, ptr %i11, align 8
530 %i14 = getelementptr inbounds i8, ptr %i7, i64 4005
531 %i16 = load i64, ptr %i14, align 8
532 %i17 = getelementptr inbounds i8, ptr %i7, i64 4009
533 %i19 = load i64, ptr %i17, align 8
534 %i20 = getelementptr inbounds i8, ptr %arg1, i64 %i5
535 %i21 = getelementptr inbounds i8, ptr %i20, i64 4001
536 %i23 = load i64, ptr %i21, align 8
537 %i24 = getelementptr inbounds i8, ptr %i20, i64 4010
538 %i26 = load i64, ptr %i24, align 8
539 %i27 = getelementptr inbounds i8, ptr %i20, i64 4005
540 %i29 = load i64, ptr %i27, align 8
541 %i30 = getelementptr inbounds i8, ptr %i20, i64 4009
542 %i32 = load i64, ptr %i30, align 8
543 %i33 = mul i64 %i13, %i10
544 %i34 = mul i64 %i33, %i16
545 %i35 = mul i64 %i34, %i19
546 %i36 = mul i64 %i35, %i23
547 %i37 = mul i64 %i36, %i26
548 %i38 = mul i64 %i37, %i29
549 %i39 = mul i64 %i38, %i32
550 %i40 = add i64 %i39, %i6
551 %i41 = add nuw i64 %i5, 1
552 %i42 = icmp ult i64 %i41, %i
553 br i1 %i42, label %bb4, label %bb43
555 bb43: ; preds = %bb4, %bb
556 %i44 = phi i64 [ 0, %bb ], [ %i40, %bb4 ]
557 %i45 = add i64 %i44, %i
561 ; test_ds_cross_basic_blocks:
563 ;unsigned long foo(char *p, int count)
565 ; unsigned long i=0, res=0;
572 ; unsigned long x1, x2, x3, x4, x5, x6;
573 ; x1=x2=x3=x4=x5=x6=1;
574 ; for (; i < count ; i++) {
575 ; if (arr[i] % 3 == 1) {
576 ; x1 += *(unsigned long *)(p + i + DISP1);
577 ; x2 += *(unsigned long *)(p + i + DISP2);
579 ; else if (arr[i] % 3 == 2) {
580 ; x3 += *(unsigned long *)(p + i + DISP3);
581 ; x4 += *(unsigned long *)(p + i + DISP5);
584 ; x5 += *(unsigned long *)(p + i + DISP4);
585 ; x6 += *(unsigned long *)(p + i + DISP6);
587 ; res += x1*x2*x3*x4*x5*x6;
592 @arr = external local_unnamed_addr global ptr, align 8
594 define i64 @test_ds_cross_basic_blocks(ptr %arg, i32 signext %arg1) {
595 ; CHECK-LABEL: test_ds_cross_basic_blocks:
596 ; CHECK: # %bb.0: # %bb
597 ; CHECK-NEXT: cmplwi r4, 0
598 ; CHECK-NEXT: beq cr0, .LBB6_9
599 ; CHECK-NEXT: # %bb.1: # %bb3
600 ; CHECK-NEXT: addis r5, r2, .LC0@toc@ha
601 ; CHECK-NEXT: cmpldi r4, 1
602 ; CHECK-NEXT: li r7, 1
603 ; CHECK-NEXT: addi r6, r3, 4009
604 ; CHECK-NEXT: std r28, -32(r1) # 8-byte Folded Spill
605 ; CHECK-NEXT: ld r5, .LC0@toc@l(r5)
606 ; CHECK-NEXT: iselgt r3, r4, r7
607 ; CHECK-NEXT: std r29, -24(r1) # 8-byte Folded Spill
608 ; CHECK-NEXT: std r30, -16(r1) # 8-byte Folded Spill
609 ; CHECK-NEXT: li r4, -7
610 ; CHECK-NEXT: li r8, -6
611 ; CHECK-NEXT: li r9, 1
612 ; CHECK-NEXT: li r10, 1
613 ; CHECK-NEXT: li r11, 1
614 ; CHECK-NEXT: li r12, 1
615 ; CHECK-NEXT: li r30, 1
616 ; CHECK-NEXT: ld r5, 0(r5)
617 ; CHECK-NEXT: mtctr r3
618 ; CHECK-NEXT: li r3, 0
619 ; CHECK-NEXT: addi r5, r5, -1
620 ; CHECK-NEXT: b .LBB6_4
621 ; CHECK-NEXT: .p2align 4
622 ; CHECK-NEXT: .LBB6_2: # %bb18
624 ; CHECK-NEXT: addi r29, r6, -9
625 ; CHECK-NEXT: ld r0, 0(r29)
626 ; CHECK-NEXT: add r30, r0, r30
627 ; CHECK-NEXT: ld r0, -8(r6)
628 ; CHECK-NEXT: add r12, r0, r12
629 ; CHECK-NEXT: .LBB6_3: # %bb49
631 ; CHECK-NEXT: mulld r0, r12, r30
632 ; CHECK-NEXT: addi r6, r6, 1
633 ; CHECK-NEXT: mulld r0, r0, r11
634 ; CHECK-NEXT: mulld r0, r0, r10
635 ; CHECK-NEXT: mulld r0, r0, r9
636 ; CHECK-NEXT: maddld r3, r0, r7, r3
637 ; CHECK-NEXT: bdz .LBB6_8
638 ; CHECK-NEXT: .LBB6_4: # %bb5
640 ; CHECK-NEXT: lbzu r0, 1(r5)
641 ; CHECK-NEXT: mulli r29, r0, 171
642 ; CHECK-NEXT: rlwinm r28, r29, 24, 8, 30
643 ; CHECK-NEXT: srwi r29, r29, 9
644 ; CHECK-NEXT: add r29, r29, r28
645 ; CHECK-NEXT: sub r0, r0, r29
646 ; CHECK-NEXT: clrlwi r0, r0, 24
647 ; CHECK-NEXT: cmplwi r0, 1
648 ; CHECK-NEXT: beq cr0, .LBB6_2
649 ; CHECK-NEXT: # %bb.5: # %bb28
651 ; CHECK-NEXT: cmplwi r0, 2
652 ; CHECK-NEXT: bne cr0, .LBB6_7
653 ; CHECK-NEXT: # %bb.6: # %bb31
655 ; CHECK-NEXT: ldx r0, r6, r4
656 ; CHECK-NEXT: add r11, r0, r11
657 ; CHECK-NEXT: ld r0, -4(r6)
658 ; CHECK-NEXT: add r10, r0, r10
659 ; CHECK-NEXT: b .LBB6_3
660 ; CHECK-NEXT: .p2align 4
661 ; CHECK-NEXT: .LBB6_7: # %bb40
663 ; CHECK-NEXT: ldx r0, r6, r8
664 ; CHECK-NEXT: add r9, r0, r9
665 ; CHECK-NEXT: ld r0, 0(r6)
666 ; CHECK-NEXT: add r7, r0, r7
667 ; CHECK-NEXT: b .LBB6_3
668 ; CHECK-NEXT: .LBB6_8:
669 ; CHECK-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
670 ; CHECK-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
671 ; CHECK-NEXT: ld r28, -32(r1) # 8-byte Folded Reload
673 ; CHECK-NEXT: .LBB6_9:
674 ; CHECK-NEXT: li r3, 0
677 %i = sext i32 %arg1 to i64
678 %i2 = icmp eq i32 %arg1, 0
679 br i1 %i2, label %bb64, label %bb3
682 %i4 = load ptr, ptr @arr, align 8
685 bb5: ; preds = %bb49, %bb3
686 %i6 = phi i64 [ 1, %bb3 ], [ %i55, %bb49 ]
687 %i7 = phi i64 [ 1, %bb3 ], [ %i54, %bb49 ]
688 %i8 = phi i64 [ 1, %bb3 ], [ %i53, %bb49 ]
689 %i9 = phi i64 [ 1, %bb3 ], [ %i52, %bb49 ]
690 %i10 = phi i64 [ 1, %bb3 ], [ %i51, %bb49 ]
691 %i11 = phi i64 [ 1, %bb3 ], [ %i50, %bb49 ]
692 %i12 = phi i64 [ 0, %bb3 ], [ %i62, %bb49 ]
693 %i13 = phi i64 [ 0, %bb3 ], [ %i61, %bb49 ]
694 %i14 = getelementptr inbounds i8, ptr %i4, i64 %i12
695 %i15 = load i8, ptr %i14, align 1
696 %i16 = urem i8 %i15, 3
697 %i17 = icmp eq i8 %i16, 1
698 br i1 %i17, label %bb18, label %bb28
701 %i19 = getelementptr inbounds i8, ptr %arg, i64 %i12
702 %i20 = getelementptr inbounds i8, ptr %i19, i64 4000
703 %i22 = load i64, ptr %i20, align 8
704 %i23 = add i64 %i22, %i11
705 %i24 = getelementptr inbounds i8, ptr %i19, i64 4001
706 %i26 = load i64, ptr %i24, align 8
707 %i27 = add i64 %i26, %i10
711 %i29 = icmp eq i8 %i16, 2
712 %i30 = getelementptr inbounds i8, ptr %arg, i64 %i12
713 br i1 %i29, label %bb31, label %bb40
715 bb31: ; preds = %bb28
716 %i32 = getelementptr inbounds i8, ptr %i30, i64 4002
717 %i34 = load i64, ptr %i32, align 8
718 %i35 = add i64 %i34, %i9
719 %i36 = getelementptr inbounds i8, ptr %i30, i64 4005
720 %i38 = load i64, ptr %i36, align 8
721 %i39 = add i64 %i38, %i8
724 bb40: ; preds = %bb28
725 %i41 = getelementptr inbounds i8, ptr %i30, i64 4003
726 %i43 = load i64, ptr %i41, align 8
727 %i44 = add i64 %i43, %i7
728 %i45 = getelementptr inbounds i8, ptr %i30, i64 4009
729 %i47 = load i64, ptr %i45, align 8
730 %i48 = add i64 %i47, %i6
733 bb49: ; preds = %bb40, %bb31, %bb18
734 %i50 = phi i64 [ %i23, %bb18 ], [ %i11, %bb31 ], [ %i11, %bb40 ]
735 %i51 = phi i64 [ %i27, %bb18 ], [ %i10, %bb31 ], [ %i10, %bb40 ]
736 %i52 = phi i64 [ %i9, %bb18 ], [ %i35, %bb31 ], [ %i9, %bb40 ]
737 %i53 = phi i64 [ %i8, %bb18 ], [ %i39, %bb31 ], [ %i8, %bb40 ]
738 %i54 = phi i64 [ %i7, %bb18 ], [ %i7, %bb31 ], [ %i44, %bb40 ]
739 %i55 = phi i64 [ %i6, %bb18 ], [ %i6, %bb31 ], [ %i48, %bb40 ]
740 %i56 = mul i64 %i51, %i50
741 %i57 = mul i64 %i56, %i52
742 %i58 = mul i64 %i57, %i53
743 %i59 = mul i64 %i58, %i54
744 %i60 = mul i64 %i59, %i55
745 %i61 = add i64 %i60, %i13
746 %i62 = add nuw i64 %i12, 1
747 %i63 = icmp ult i64 %i62, %i
748 br i1 %i63, label %bb5, label %bb64
750 bb64: ; preds = %bb49, %bb
751 %i65 = phi i64 [ 0, %bb ], [ %i61, %bb49 ]
756 ;float test_ds_float(char *p, int count) {
763 ; for (; i < count ; i++) {
764 ; float x1 = *(float *)(p + i + DISP1);
765 ; float x2 = *(float *)(p + i + DISP2);
766 ; float x3 = *(float *)(p + i + DISP3);
767 ; float x4 = *(float *)(p + i + DISP4);
768 ; res += x1*x2*x3*x4;
773 define float @test_ds_float(ptr %arg, i32 signext %arg1) {
774 ; CHECK-LABEL: test_ds_float:
775 ; CHECK: # %bb.0: # %bb
776 ; CHECK-NEXT: cmpwi r4, 0
777 ; CHECK-NEXT: ble cr0, .LBB7_4
778 ; CHECK-NEXT: # %bb.1: # %bb2
779 ; CHECK-NEXT: clrldi r4, r4, 32
780 ; CHECK-NEXT: addi r3, r3, 4002
781 ; CHECK-NEXT: xxlxor f1, f1, f1
782 ; CHECK-NEXT: mtctr r4
783 ; CHECK-NEXT: li r4, -1
784 ; CHECK-NEXT: .p2align 4
785 ; CHECK-NEXT: .LBB7_2: # %bb4
787 ; CHECK-NEXT: lfsx f0, r3, r4
788 ; CHECK-NEXT: lfs f2, 0(r3)
789 ; CHECK-NEXT: xsmulsp f0, f0, f2
790 ; CHECK-NEXT: lfs f3, 20(r3)
791 ; CHECK-NEXT: xsmulsp f0, f0, f3
792 ; CHECK-NEXT: lfs f4, 60(r3)
793 ; CHECK-NEXT: addi r3, r3, 1
794 ; CHECK-NEXT: xsmulsp f0, f0, f4
795 ; CHECK-NEXT: xsaddsp f1, f1, f0
796 ; CHECK-NEXT: bdnz .LBB7_2
797 ; CHECK-NEXT: # %bb.3: # %bb26
799 ; CHECK-NEXT: .LBB7_4:
800 ; CHECK-NEXT: xxlxor f1, f1, f1
803 %i = icmp sgt i32 %arg1, 0
804 br i1 %i, label %bb2, label %bb26
807 %i3 = zext i32 %arg1 to i64
810 bb4: ; preds = %bb4, %bb2
811 %i5 = phi i64 [ 0, %bb2 ], [ %i24, %bb4 ]
812 %i6 = phi float [ 0.000000e+00, %bb2 ], [ %i23, %bb4 ]
813 %i7 = getelementptr inbounds i8, ptr %arg, i64 %i5
814 %i8 = getelementptr inbounds i8, ptr %i7, i64 4001
815 %i10 = load float, ptr %i8, align 4
816 %i11 = getelementptr inbounds i8, ptr %i7, i64 4002
817 %i13 = load float, ptr %i11, align 4
818 %i14 = getelementptr inbounds i8, ptr %i7, i64 4022
819 %i16 = load float, ptr %i14, align 4
820 %i17 = getelementptr inbounds i8, ptr %i7, i64 4062
821 %i19 = load float, ptr %i17, align 4
822 %i20 = fmul float %i10, %i13
823 %i21 = fmul float %i20, %i16
824 %i22 = fmul float %i21, %i19
825 %i23 = fadd float %i6, %i22
826 %i24 = add nuw nsw i64 %i5, 1
827 %i25 = icmp eq i64 %i24, %i3
828 br i1 %i25, label %bb26, label %bb4
830 bb26: ; preds = %bb4, %bb
831 %i27 = phi float [ 0.000000e+00, %bb ], [ %i23, %bb4 ]
835 ; test_ds_combine_float_int:
836 ;float test_ds_combine_float_int(char *p, int count) {
843 ; for (; i < count ; i++) {
844 ; float x1 = *(float *)(p + i + DISP1);
845 ; unsigned long x2 = *(unsigned long*)(p + i + DISP2);
846 ; float x3 = *(float *)(p + i + DISP3);
847 ; float x4 = *(float *)(p + i + DISP4);
848 ; res += x1*x2*x3*x4;
853 define float @test_ds_combine_float_int(ptr %arg, i32 signext %arg1) {
854 ; CHECK-LABEL: test_ds_combine_float_int:
855 ; CHECK: # %bb.0: # %bb
856 ; CHECK-NEXT: cmpwi r4, 0
857 ; CHECK-NEXT: ble cr0, .LBB8_4
858 ; CHECK-NEXT: # %bb.1: # %bb2
859 ; CHECK-NEXT: clrldi r4, r4, 32
860 ; CHECK-NEXT: addi r3, r3, 4002
861 ; CHECK-NEXT: xxlxor f1, f1, f1
862 ; CHECK-NEXT: mtctr r4
863 ; CHECK-NEXT: li r4, -1
864 ; CHECK-NEXT: .p2align 4
865 ; CHECK-NEXT: .LBB8_2: # %bb4
867 ; CHECK-NEXT: lfd f4, 0(r3)
868 ; CHECK-NEXT: lfsx f0, r3, r4
869 ; CHECK-NEXT: xscvuxdsp f4, f4
870 ; CHECK-NEXT: lfs f2, 20(r3)
871 ; CHECK-NEXT: lfs f3, 60(r3)
872 ; CHECK-NEXT: addi r3, r3, 1
873 ; CHECK-NEXT: xsmulsp f0, f0, f4
874 ; CHECK-NEXT: xsmulsp f0, f2, f0
875 ; CHECK-NEXT: xsmulsp f0, f3, f0
876 ; CHECK-NEXT: xsaddsp f1, f1, f0
877 ; CHECK-NEXT: bdnz .LBB8_2
878 ; CHECK-NEXT: # %bb.3: # %bb27
880 ; CHECK-NEXT: .LBB8_4:
881 ; CHECK-NEXT: xxlxor f1, f1, f1
884 %i = icmp sgt i32 %arg1, 0
885 br i1 %i, label %bb2, label %bb27
888 %i3 = zext i32 %arg1 to i64
891 bb4: ; preds = %bb4, %bb2
892 %i5 = phi i64 [ 0, %bb2 ], [ %i25, %bb4 ]
893 %i6 = phi float [ 0.000000e+00, %bb2 ], [ %i24, %bb4 ]
894 %i7 = getelementptr inbounds i8, ptr %arg, i64 %i5
895 %i8 = getelementptr inbounds i8, ptr %i7, i64 4001
896 %i10 = load float, ptr %i8, align 4
897 %i11 = getelementptr inbounds i8, ptr %i7, i64 4002
898 %i13 = load i64, ptr %i11, align 8
899 %i14 = getelementptr inbounds i8, ptr %i7, i64 4022
900 %i16 = load float, ptr %i14, align 4
901 %i17 = getelementptr inbounds i8, ptr %i7, i64 4062
902 %i19 = load float, ptr %i17, align 4
903 %i20 = uitofp i64 %i13 to float
904 %i21 = fmul float %i10, %i20
905 %i22 = fmul float %i16, %i21
906 %i23 = fmul float %i19, %i22
907 %i24 = fadd float %i6, %i23
908 %i25 = add nuw nsw i64 %i5, 1
909 %i26 = icmp eq i64 %i25, %i3
910 br i1 %i26, label %bb27, label %bb4
912 bb27: ; preds = %bb4, %bb
913 %i28 = phi float [ 0.000000e+00, %bb ], [ %i24, %bb4 ]
918 ; long long test_ds_lwa_prep(char *p, int count) {
919 ; long long i=0, res=0;
924 ; for (; i < count ; i++) {
925 ; long long x1 = *(int *)(p + i + DISP1);
926 ; long long x2 = *(int *)(p + i + DISP2);
927 ; long long x3 = *(int *)(p + i + DISP3);
928 ; long long x4 = *(int *)(p + i + DISP4);
929 ; res += x1*x2*x3*x4;
931 ; return res + count;
934 define i64 @test_ds_lwa_prep(ptr %arg, i32 signext %arg1) {
935 ; CHECK-LABEL: test_ds_lwa_prep:
936 ; CHECK: # %bb.0: # %bb
937 ; CHECK-NEXT: cmpwi r4, 0
938 ; CHECK-NEXT: ble cr0, .LBB9_4
939 ; CHECK-NEXT: # %bb.1: # %bb3.preheader
940 ; CHECK-NEXT: mtctr r4
941 ; CHECK-NEXT: addi r5, r3, 2
942 ; CHECK-NEXT: li r3, 0
943 ; CHECK-NEXT: li r6, -1
944 ; CHECK-NEXT: .p2align 4
945 ; CHECK-NEXT: .LBB9_2: # %bb3
947 ; CHECK-NEXT: lwax r7, r5, r6
948 ; CHECK-NEXT: lwa r8, 0(r5)
949 ; CHECK-NEXT: lwa r9, 4(r5)
950 ; CHECK-NEXT: lwa r10, 8(r5)
951 ; CHECK-NEXT: addi r5, r5, 1
952 ; CHECK-NEXT: mulld r7, r8, r7
953 ; CHECK-NEXT: mulld r7, r7, r9
954 ; CHECK-NEXT: maddld r3, r7, r10, r3
955 ; CHECK-NEXT: bdnz .LBB9_2
956 ; CHECK-NEXT: # %bb.3: # %bb29
957 ; CHECK-NEXT: add r3, r3, r4
959 ; CHECK-NEXT: .LBB9_4:
960 ; CHECK-NEXT: addi r3, r4, 0
963 %i = sext i32 %arg1 to i64
964 %i2 = icmp sgt i32 %arg1, 0
965 br i1 %i2, label %bb3, label %bb29
967 bb3: ; preds = %bb3, %bb
968 %i4 = phi i64 [ %i27, %bb3 ], [ 0, %bb ]
969 %i5 = phi i64 [ %i26, %bb3 ], [ 0, %bb ]
970 %i6 = getelementptr inbounds i8, ptr %arg, i64 %i4
971 %i7 = getelementptr inbounds i8, ptr %i6, i64 1
972 %i9 = load i32, ptr %i7, align 4
973 %i10 = sext i32 %i9 to i64
974 %i11 = getelementptr inbounds i8, ptr %i6, i64 2
975 %i13 = load i32, ptr %i11, align 4
976 %i14 = sext i32 %i13 to i64
977 %i15 = getelementptr inbounds i8, ptr %i6, i64 6
978 %i17 = load i32, ptr %i15, align 4
979 %i18 = sext i32 %i17 to i64
980 %i19 = getelementptr inbounds i8, ptr %i6, i64 10
981 %i21 = load i32, ptr %i19, align 4
982 %i22 = sext i32 %i21 to i64
983 %i23 = mul nsw i64 %i14, %i10
984 %i24 = mul nsw i64 %i23, %i18
985 %i25 = mul nsw i64 %i24, %i22
986 %i26 = add nsw i64 %i25, %i5
987 %i27 = add nuw nsw i64 %i4, 1
988 %i28 = icmp eq i64 %i27, %i
989 br i1 %i28, label %bb29, label %bb3
991 bb29: ; preds = %bb3, %bb
992 %i30 = phi i64 [ 0, %bb ], [ %i26, %bb3 ]
993 %i31 = add nsw i64 %i30, %i