llvm.org GIT mirror llvm / 8e8c9a8
Revert r269093: Enable loopreroll for sext of loop control only IV git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269117 91177308-0d34-0410-b5e6-96231b3b80d8 Lawrence Hu 3 years ago
1 changed file(s) with 186 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt -S -loop-reroll %s | FileCheck %s
1 target triple = "aarch64--linux-gnu"
2
3 define void @test(i32 %n, float* %arrayidx200, float* %arrayidx164, float* %arrayidx172) {
4 entry:
5 %rem.i = srem i32 %n, 4
6 %t22 = load float, float* %arrayidx172, align 4
7 %cmp.9 = icmp eq i32 %n, 0
8 %t7 = sext i32 %n to i64
9 br i1 %cmp.9, label %while.end, label %while.body.preheader
10
11 while.body.preheader:
12 br label %while.body
13
14 while.body:
15 ;CHECK-LABEL: while.body:
16 ;CHECK-NEXT: %indvars.iv.i423 = phi i64 [ %indvars.iv.next.i424, %while.body ], [ 0, %while.body.preheader ]
17 ;CHECK-NEXT: [[T1:%[0-9]+]] = trunc i64 %indvars.iv.i423 to i32
18 ;CHECK-NEXT: %arrayidx62.i = getelementptr inbounds float, float* %arrayidx200, i64 %indvars.iv.i423
19 ;CHECK-NEXT: %t1 = load float, float* %arrayidx62.i, align 4
20 ;CHECK-NEXT: %arrayidx64.i = getelementptr inbounds float, float* %arrayidx164, i64 %indvars.iv.i423
21 ;CHECK-NEXT: %t2 = load float, float* %arrayidx64.i, align 4
22 ;CHECK-NEXT: %mul65.i = fmul fast float %t2, %t22
23 ;CHECK-NEXT: %add66.i = fadd fast float %mul65.i, %t1
24 ;CHECK-NEXT: store float %add66.i, float* %arrayidx62.i, align 4
25 ;CHECK-NEXT: %indvars.iv.next.i424 = add i64 %indvars.iv.i423, 1
26 ;CHECK-NEXT: [[T2:%[0-9]+]] = sext i32 [[T1]] to i64
27 ;CHECK-NEXT: %exitcond = icmp eq i64 [[T2]], %{{[0-9]+}}
28 ;CHECK-NEXT: br i1 %exitcond, label %while.end.loopexit, label %while.body
29
30 %indvars.iv.i423 = phi i64 [ %indvars.iv.next.i424, %while.body ], [ 0, %while.body.preheader ]
31 %i.22.i = phi i32 [ %add103.i, %while.body ], [ %rem.i, %while.body.preheader ]
32 %arrayidx62.i = getelementptr inbounds float, float* %arrayidx200, i64 %indvars.iv.i423
33 %t1 = load float, float* %arrayidx62.i, align 4
34 %arrayidx64.i = getelementptr inbounds float, float* %arrayidx164, i64 %indvars.iv.i423
35 %t2 = load float, float* %arrayidx64.i, align 4
36 %mul65.i = fmul fast float %t2, %t22
37 %add66.i = fadd fast float %mul65.i, %t1
38 store float %add66.i, float* %arrayidx62.i, align 4
39 %t3 = add nsw i64 %indvars.iv.i423, 1
40 %arrayidx71.i = getelementptr inbounds float, float* %arrayidx200, i64 %t3
41 %t4 = load float, float* %arrayidx71.i, align 4
42 %arrayidx74.i = getelementptr inbounds float, float* %arrayidx164, i64 %t3
43 %t5 = load float, float* %arrayidx74.i, align 4
44 %mul75.i = fmul fast float %t5, %t22
45 %add76.i = fadd fast float %mul75.i, %t4
46 store float %add76.i, float* %arrayidx71.i, align 4
47 %add103.i = add nsw i32 %i.22.i, 2
48 %t6 = sext i32 %add103.i to i64
49 %cmp58.i = icmp slt i64 %t6, %t7
50 %indvars.iv.next.i424 = add i64 %indvars.iv.i423, 2
51 br i1 %cmp58.i, label %while.body, label %while.end.loopexit
52
53 while.end.loopexit:
54 br label %while.end
55
56 while.end:
57 ret void
58 }
59
60 ; Function Attrs: noinline norecurse nounwind
61 define i32 @test2(i64 %n, i32* nocapture %x, i32* nocapture readonly %y) {
62 entry:
63 %cmp18 = icmp sgt i64 %n, 0
64 br i1 %cmp18, label %for.body.preheader, label %for.end
65
66 for.body.preheader: ; preds = %entry
67 br label %for.body
68
69 for.body: ; preds = %for.body.preheader, %for.body
70
71 ;CHECK: for.body:
72 ;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
73 ;CHECK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvar
74 ;CHECK-NEXT: [[T1:%[0-9]+]] = load i32, i32* %arrayidx, align 4
75 ;CHECK-NEXT: %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvar
76 ;CHECK-NEXT: store i32 [[T1]], i32* %arrayidx3, align 4
77 ;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
78 ;CHECK-NEXT: %exitcond = icmp eq i64 %indvar, %{{[0-9]+}}
79 ;CHECK-NEXT: br i1 %exitcond, label %for.end.loopexit, label %for.body
80
81 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
82 %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvars.iv
83 %0 = load i32, i32* %arrayidx, align 4
84 %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
85 store i32 %0, i32* %arrayidx3, align 4
86 %1 = or i64 %indvars.iv, 1
87 %arrayidx5 = getelementptr inbounds i32, i32* %y, i64 %1
88 %2 = load i32, i32* %arrayidx5, align 4
89 %arrayidx8 = getelementptr inbounds i32, i32* %x, i64 %1
90 store i32 %2, i32* %arrayidx8, align 4
91 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
92 %cmp = icmp slt i64 %indvars.iv.next, %n
93 br i1 %cmp, label %for.body, label %for.end.loopexit
94
95 for.end.loopexit: ; preds = %for.body
96 br label %for.end
97
98 for.end: ; preds = %for.end.loopexit, %entry
99 ret i32 0
100 }
101
102 ; Function Attrs: noinline norecurse nounwind
103 define i32 @test3(i32 %n, i32* nocapture %x, i32* nocapture readonly %y) {
104 entry:
105 %cmp21 = icmp sgt i32 %n, 0
106 br i1 %cmp21, label %for.body.preheader, label %for.end
107
108 for.body.preheader: ; preds = %entry
109 br label %for.body
110
111 for.body: ; preds = %for.body.preheader, %for.body
112
113 ;CHECK: for.body:
114 ;CHECK: %add12 = add i8 %i.022, 2
115 ;CHECK-NEXT: %conv = sext i8 %add12 to i32
116 ;CHECK-NEXT: %cmp = icmp slt i32 %conv, %n
117 ;CHECK-NEXT: br i1 %cmp, label %for.body, label %for.end.loopexit
118
119 %conv23 = phi i32 [ %conv, %for.body ], [ 0, %for.body.preheader ]
120 %i.022 = phi i8 [ %add12, %for.body ], [ 0, %for.body.preheader ]
121 %idxprom = sext i8 %i.022 to i64
122 %arrayidx = getelementptr inbounds i32, i32* %y, i64 %idxprom
123 %0 = load i32, i32* %arrayidx, align 4
124 %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %idxprom
125 store i32 %0, i32* %arrayidx3, align 4
126 %add = or i32 %conv23, 1
127 %idxprom5 = sext i32 %add to i64
128 %arrayidx6 = getelementptr inbounds i32, i32* %y, i64 %idxprom5
129 %1 = load i32, i32* %arrayidx6, align 4
130 %arrayidx10 = getelementptr inbounds i32, i32* %x, i64 %idxprom5
131 store i32 %1, i32* %arrayidx10, align 4
132 %add12 = add i8 %i.022, 2
133 %conv = sext i8 %add12 to i32
134 %cmp = icmp slt i32 %conv, %n
135 br i1 %cmp, label %for.body, label %for.end.loopexit
136
137 for.end.loopexit: ; preds = %for.body
138 br label %for.end
139
140 for.end: ; preds = %for.end.loopexit, %entry
141 ret i32 0
142 }
143
144 ; Function Attrs: noinline norecurse nounwind
145 define i32 @test4(i64 %n, i32* nocapture %x, i32* nocapture readonly %y) {
146 entry:
147 %cmp18 = icmp eq i64 %n, 0
148 br i1 %cmp18, label %for.end, label %for.body.preheader
149
150 for.body.preheader: ; preds = %entry
151 br label %for.body
152
153 for.body: ; preds = %for.body.preheader, %for.body
154
155 ;CHECK: for.body:
156 ;CHECK-NEXT: %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.preheader ]
157 ;CHECK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvar
158 ;CHECK-NEXT: [[T1:%[0-9]+]] = load i32, i32* %arrayidx, align 4
159 ;CHECK-NEXT: %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvar
160 ;CHECK-NEXT: store i32 [[T1]], i32* %arrayidx3, align 4
161 ;CHECK-NEXT: %indvar.next = add i64 %indvar, 1
162 ;CHECK-NEXT: %exitcond = icmp eq i64 %indvar, %{{[0-9]+}}
163 ;CHECK-NEXT: br i1 %exitcond, label %for.end.loopexit, label %for.body
164
165 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
166 %arrayidx = getelementptr inbounds i32, i32* %y, i64 %indvars.iv
167 %0 = load i32, i32* %arrayidx, align 4
168 %arrayidx3 = getelementptr inbounds i32, i32* %x, i64 %indvars.iv
169 store i32 %0, i32* %arrayidx3, align 4
170 %1 = or i64 %indvars.iv, 1
171 %arrayidx5 = getelementptr inbounds i32, i32* %y, i64 %1
172 %2 = load i32, i32* %arrayidx5, align 4
173 %arrayidx8 = getelementptr inbounds i32, i32* %x, i64 %1
174 store i32 %2, i32* %arrayidx8, align 4
175 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
176 %cmp = icmp ult i64 %indvars.iv.next, %n
177 br i1 %cmp, label %for.body, label %for.end.loopexit
178
179 for.end.loopexit: ; preds = %for.body
180 br label %for.end
181
182 for.end: ; preds = %for.end.loopexit, %entry
183 ret i32 0
184 }
185