1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -disable-lsr -ppc-asm-full-reg-names -verify-machineinstrs \
3 ; RUN: -ppc-formprep-update-nonconst-inc -mtriple=powerpc64le-unknown-linux-gnu \
4 ; RUN: -mcpu=pwr9 < %s | FileCheck %s
6 ; long long foo(char *p, int n, int count) {
9 ; for (int i = 0; i < n; i++) {
10 ; sum += *(unsigned long long *)(p + j + 5);
11 ; sum += *(unsigned long long *)(p + j + 9);
17 define i64 @foo(ptr %p, i32 signext %n, i32 signext %count) {
19 ; CHECK: # %bb.0: # %entry
20 ; CHECK-NEXT: cmpwi r4, 0
21 ; CHECK-NEXT: ble cr0, .LBB0_4
22 ; CHECK-NEXT: # %bb.1: # %for.body.preheader
23 ; CHECK-NEXT: addi r6, r3, 5
24 ; CHECK-NEXT: addi r3, r4, -1
25 ; CHECK-NEXT: clrldi r3, r3, 32
26 ; CHECK-NEXT: addi r3, r3, 1
27 ; CHECK-NEXT: mtctr r3
28 ; CHECK-NEXT: li r3, 0
29 ; CHECK-NEXT: .p2align 5
30 ; CHECK-NEXT: .LBB0_2: # %for.body
32 ; CHECK-NEXT: ld r4, 0(r6)
33 ; CHECK-NEXT: add r3, r4, r3
34 ; CHECK-NEXT: ld r4, 4(r6)
35 ; CHECK-NEXT: add r6, r6, r5
36 ; CHECK-NEXT: add r3, r3, r4
37 ; CHECK-NEXT: bdnz .LBB0_2
38 ; CHECK-NEXT: # %bb.3: # %for.cond.cleanup
40 ; CHECK-NEXT: .LBB0_4:
41 ; CHECK-NEXT: li r3, 0
44 %cmp16 = icmp sgt i32 %n, 0
45 br i1 %cmp16, label %for.body.preheader, label %for.cond.cleanup
47 for.body.preheader: ; preds = %entry
48 %0 = sext i32 %count to i64
51 for.cond.cleanup: ; preds = %for.body, %entry
52 %sum.0.lcssa = phi i64 [ 0, %entry ], [ %add5, %for.body ]
55 for.body: ; preds = %for.body.preheader, %for.body
56 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
57 %i.019 = phi i32 [ 0, %for.body.preheader ], [ %inc, %for.body ]
58 %sum.018 = phi i64 [ 0, %for.body.preheader ], [ %add5, %for.body ]
59 %add.ptr = getelementptr inbounds i8, ptr %p, i64 %indvars.iv
60 %add.ptr1 = getelementptr inbounds i8, ptr %add.ptr, i64 5
61 %1 = load i64, ptr %add.ptr1, align 8
62 %add = add i64 %1, %sum.018
63 %add.ptr4 = getelementptr inbounds i8, ptr %add.ptr, i64 9
64 %2 = load i64, ptr %add.ptr4, align 8
65 %add5 = add i64 %add, %2
66 %indvars.iv.next = add nsw i64 %indvars.iv, %0
67 %inc = add nuw nsw i32 %i.019, 1
68 %exitcond.not = icmp eq i32 %inc, %n
69 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
72 ; char foo1(char *p, int n, int count) {
75 ; for (int i = 0; i < n; i++) {
76 ; sum += *(p + j + 1000);
82 define zeroext i8 @foo1(ptr %p, i32 signext %n, i32 signext %count) {
84 ; CHECK: # %bb.0: # %entry
85 ; CHECK-NEXT: cmpwi r4, 0
86 ; CHECK-NEXT: ble cr0, .LBB1_4
87 ; CHECK-NEXT: # %bb.1: # %for.body.preheader
88 ; CHECK-NEXT: sub r3, r3, r5
89 ; CHECK-NEXT: addi r6, r3, 1000
90 ; CHECK-NEXT: addi r3, r4, -1
91 ; CHECK-NEXT: clrldi r3, r3, 32
92 ; CHECK-NEXT: addi r3, r3, 1
93 ; CHECK-NEXT: mtctr r3
94 ; CHECK-NEXT: li r3, 0
95 ; CHECK-NEXT: .p2align 4
96 ; CHECK-NEXT: .LBB1_2: # %for.body
98 ; CHECK-NEXT: lbzux r4, r6, r5
99 ; CHECK-NEXT: add r3, r4, r3
100 ; CHECK-NEXT: bdnz .LBB1_2
101 ; CHECK-NEXT: # %bb.3: # %for.cond.cleanup
102 ; CHECK-NEXT: clrldi r3, r3, 56
104 ; CHECK-NEXT: .LBB1_4:
105 ; CHECK-NEXT: li r3, 0
108 %cmp10 = icmp sgt i32 %n, 0
109 br i1 %cmp10, label %for.body.preheader, label %for.cond.cleanup
111 for.body.preheader: ; preds = %entry
112 %0 = sext i32 %count to i64
113 %add.ptr = getelementptr inbounds i8, ptr %p, i64 1000
116 for.cond.cleanup: ; preds = %for.body, %entry
117 %sum.0.lcssa = phi i8 [ 0, %entry ], [ %add, %for.body ]
120 for.body: ; preds = %for.body.preheader, %for.body
121 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
122 %i.013 = phi i32 [ 0, %for.body.preheader ], [ %inc, %for.body ]
123 %sum.012 = phi i8 [ 0, %for.body.preheader ], [ %add, %for.body ]
124 %add.ptr1 = getelementptr inbounds i8, ptr %add.ptr, i64 %indvars.iv
125 %1 = load i8, ptr %add.ptr1, align 1
126 %add = add i8 %1, %sum.012
127 %indvars.iv.next = add nsw i64 %indvars.iv, %0
128 %inc = add nuw nsw i32 %i.013, 1
129 %exitcond.not = icmp eq i32 %inc, %n
130 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body