Skip to content

Commit 366e469

Browse files
committed
[RISCV] Add cost tests for more interleave factors. NFC
This shows how we're not properly scaling the cost with the number of factors, i.e. a factor 8 interleave costs the same as a factor 2 interleave at VF=2.
1 parent 327124e commit 366e469

File tree

1 file changed

+237
-0
lines changed

1 file changed

+237
-0
lines changed

llvm/test/Transforms/LoopVectorize/RISCV/interleaved-cost.ll

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,240 @@ for.body:
8080
for.end:
8181
ret void
8282
}
83+
84+
%i8.4 = type {i8, i8, i8, i8}
85+
define void @i8_factor_4(ptr %data, i64 %n) {
86+
entry:
87+
br label %for.body
88+
; CHECK-LABEL: Checking a loop in 'i8_factor_4'
89+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 4 at %l0, ir<%p0>
90+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 4 at <badref>, ir<%p0>
91+
; CHECK: Cost of 2 for VF 4: INTERLEAVE-GROUP with factor 4 at %l0, ir<%p0>
92+
; CHECK: Cost of 2 for VF 4: INTERLEAVE-GROUP with factor 4 at <badref>, ir<%p0>
93+
; CHECK: Cost of 3 for VF 8: INTERLEAVE-GROUP with factor 4 at %l0, ir<%p0>
94+
; CHECK: Cost of 3 for VF 8: INTERLEAVE-GROUP with factor 4 at <badref>, ir<%p0>
95+
; CHECK: Cost of 5 for VF 16: INTERLEAVE-GROUP with factor 4 at %l0, ir<%p0>
96+
; CHECK: Cost of 5 for VF 16: INTERLEAVE-GROUP with factor 4 at <badref>, ir<%p0>
97+
; CHECK: Cost of 9 for VF 32: INTERLEAVE-GROUP with factor 4 at %l0, ir<%p0>
98+
; CHECK: Cost of 9 for VF 32: INTERLEAVE-GROUP with factor 4 at <badref>, ir<%p0>
99+
for.body:
100+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
101+
%p0 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 0
102+
%p1 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 1
103+
%p2 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 2
104+
%p3 = getelementptr inbounds %i8.4, ptr %data, i64 %i, i32 3
105+
%l0 = load i8, ptr %p0, align 1
106+
%l1 = load i8, ptr %p1, align 1
107+
%l2 = load i8, ptr %p2, align 1
108+
%l3 = load i8, ptr %p3, align 1
109+
%a0 = add i8 %l0, 1
110+
%a1 = add i8 %l1, 2
111+
%a2 = add i8 %l2, 3
112+
%a3 = add i8 %l3, 4
113+
store i8 %a0, ptr %p0, align 1
114+
store i8 %a1, ptr %p1, align 1
115+
store i8 %a2, ptr %p2, align 1
116+
store i8 %a3, ptr %p3, align 1
117+
%i.next = add nuw nsw i64 %i, 1
118+
%cond = icmp slt i64 %i.next, %n
119+
br i1 %cond, label %for.body, label %for.end
120+
121+
for.end:
122+
ret void
123+
}
124+
125+
%i8.5 = type {i8, i8, i8, i8, i8}
126+
define void @i8_factor_5(ptr %data, i64 %n) {
127+
entry:
128+
br label %for.body
129+
; CHECK-LABEL: Checking a loop in 'i8_factor_5'
130+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 5 at %l0, ir<%p0>
131+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 5 at <badref>, ir<%p0>
132+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 5 at %l0, ir<%p0>
133+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 5 at <badref>, ir<%p0>
134+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 5 at %l0, ir<%p0>
135+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 5 at <badref>, ir<%p0>
136+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 5 at %l0, ir<%p0>
137+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 5 at <badref>, ir<%p0>
138+
for.body:
139+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
140+
%p0 = getelementptr inbounds %i8.5, ptr %data, i64 %i, i32 0
141+
%p1 = getelementptr inbounds %i8.5, ptr %data, i64 %i, i32 1
142+
%p2 = getelementptr inbounds %i8.5, ptr %data, i64 %i, i32 2
143+
%p3 = getelementptr inbounds %i8.5, ptr %data, i64 %i, i32 3
144+
%p4 = getelementptr inbounds %i8.5, ptr %data, i64 %i, i32 4
145+
%l0 = load i8, ptr %p0, align 1
146+
%l1 = load i8, ptr %p1, align 1
147+
%l2 = load i8, ptr %p2, align 1
148+
%l3 = load i8, ptr %p3, align 1
149+
%l4 = load i8, ptr %p4, align 1
150+
%a0 = add i8 %l0, 1
151+
%a1 = add i8 %l1, 2
152+
%a2 = add i8 %l2, 3
153+
%a3 = add i8 %l3, 4
154+
%a4 = add i8 %l4, 5
155+
store i8 %a0, ptr %p0, align 1
156+
store i8 %a1, ptr %p1, align 1
157+
store i8 %a2, ptr %p2, align 1
158+
store i8 %a3, ptr %p3, align 1
159+
store i8 %a4, ptr %p4, align 1
160+
%i.next = add nuw nsw i64 %i, 1
161+
%cond = icmp slt i64 %i.next, %n
162+
br i1 %cond, label %for.body, label %for.end
163+
164+
for.end:
165+
ret void
166+
}
167+
168+
%i8.6 = type {i8, i8, i8, i8, i8, i8}
169+
define void @i8_factor_6(ptr %data, i64 %n) {
170+
entry:
171+
br label %for.body
172+
; CHECK-LABEL: Checking a loop in 'i8_factor_6'
173+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 6 at %l0, ir<%p0>
174+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 6 at <badref>, ir<%p0>
175+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 6 at %l0, ir<%p0>
176+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 6 at <badref>, ir<%p0>
177+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 6 at %l0, ir<%p0>
178+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 6 at <badref>, ir<%p0>
179+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 6 at %l0, ir<%p0>
180+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 6 at <badref>, ir<%p0>
181+
for.body:
182+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
183+
%p0 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 0
184+
%p1 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 1
185+
%p2 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 2
186+
%p3 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 3
187+
%p4 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 4
188+
%p5 = getelementptr inbounds %i8.6, ptr %data, i64 %i, i32 5
189+
%l0 = load i8, ptr %p0, align 1
190+
%l1 = load i8, ptr %p1, align 1
191+
%l2 = load i8, ptr %p2, align 1
192+
%l3 = load i8, ptr %p3, align 1
193+
%l4 = load i8, ptr %p4, align 1
194+
%l5 = load i8, ptr %p5, align 1
195+
%a0 = add i8 %l0, 1
196+
%a1 = add i8 %l1, 2
197+
%a2 = add i8 %l2, 3
198+
%a3 = add i8 %l3, 4
199+
%a4 = add i8 %l4, 5
200+
%a5 = add i8 %l5, 6
201+
store i8 %a0, ptr %p0, align 1
202+
store i8 %a1, ptr %p1, align 1
203+
store i8 %a2, ptr %p2, align 1
204+
store i8 %a3, ptr %p3, align 1
205+
store i8 %a4, ptr %p4, align 1
206+
store i8 %a5, ptr %p5, align 1
207+
%i.next = add nuw nsw i64 %i, 1
208+
%cond = icmp slt i64 %i.next, %n
209+
br i1 %cond, label %for.body, label %for.end
210+
211+
for.end:
212+
ret void
213+
}
214+
215+
%i8.7 = type {i8, i8, i8, i8, i8, i8, i8}
216+
define void @i8_factor_7(ptr %data, i64 %n) {
217+
entry:
218+
br label %for.body
219+
; CHECK-LABEL: Checking a loop in 'i8_factor_7'
220+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 7 at %l0, ir<%p0>
221+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 7 at <badref>, ir<%p0>
222+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 7 at %l0, ir<%p0>
223+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 7 at <badref>, ir<%p0>
224+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 7 at %l0, ir<%p0>
225+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 7 at <badref>, ir<%p0>
226+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 7 at %l0, ir<%p0>
227+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 7 at <badref>, ir<%p0>
228+
for.body:
229+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
230+
%p0 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 0
231+
%p1 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 1
232+
%p2 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 2
233+
%p3 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 3
234+
%p4 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 4
235+
%p5 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 5
236+
%p6 = getelementptr inbounds %i8.7, ptr %data, i64 %i, i32 6
237+
%l0 = load i8, ptr %p0, align 1
238+
%l1 = load i8, ptr %p1, align 1
239+
%l2 = load i8, ptr %p2, align 1
240+
%l3 = load i8, ptr %p3, align 1
241+
%l4 = load i8, ptr %p4, align 1
242+
%l5 = load i8, ptr %p5, align 1
243+
%l6 = load i8, ptr %p6, align 1
244+
%a0 = add i8 %l0, 1
245+
%a1 = add i8 %l1, 2
246+
%a2 = add i8 %l2, 3
247+
%a3 = add i8 %l3, 4
248+
%a4 = add i8 %l4, 5
249+
%a5 = add i8 %l5, 6
250+
%a6 = add i8 %l6, 7
251+
store i8 %a0, ptr %p0, align 1
252+
store i8 %a1, ptr %p1, align 1
253+
store i8 %a2, ptr %p2, align 1
254+
store i8 %a3, ptr %p3, align 1
255+
store i8 %a4, ptr %p4, align 1
256+
store i8 %a5, ptr %p5, align 1
257+
store i8 %a6, ptr %p6, align 1
258+
%i.next = add nuw nsw i64 %i, 1
259+
%cond = icmp slt i64 %i.next, %n
260+
br i1 %cond, label %for.body, label %for.end
261+
262+
for.end:
263+
ret void
264+
}
265+
266+
%i8.8 = type {i8, i8, i8, i8, i8, i8, i8, i8}
267+
define void @i8_factor_8(ptr %data, i64 %n) {
268+
entry:
269+
br label %for.body
270+
; CHECK-LABEL: Checking a loop in 'i8_factor_8'
271+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 8 at %l0, ir<%p0>
272+
; CHECK: Cost of 2 for VF 2: INTERLEAVE-GROUP with factor 8 at <badref>, ir<%p0>
273+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 8 at %l0, ir<%p0>
274+
; CHECK: Cost of 3 for VF 4: INTERLEAVE-GROUP with factor 8 at <badref>, ir<%p0>
275+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 8 at %l0, ir<%p0>
276+
; CHECK: Cost of 5 for VF 8: INTERLEAVE-GROUP with factor 8 at <badref>, ir<%p0>
277+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 8 at %l0, ir<%p0>
278+
; CHECK: Cost of 9 for VF 16: INTERLEAVE-GROUP with factor 8 at <badref>, ir<%p0>
279+
for.body:
280+
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
281+
%p0 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 0
282+
%p1 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 1
283+
%p2 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 2
284+
%p3 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 3
285+
%p4 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 4
286+
%p5 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 5
287+
%p6 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 6
288+
%p7 = getelementptr inbounds %i8.8, ptr %data, i64 %i, i32 7
289+
%l0 = load i8, ptr %p0, align 1
290+
%l1 = load i8, ptr %p1, align 1
291+
%l2 = load i8, ptr %p2, align 1
292+
%l3 = load i8, ptr %p3, align 1
293+
%l4 = load i8, ptr %p4, align 1
294+
%l5 = load i8, ptr %p5, align 1
295+
%l6 = load i8, ptr %p6, align 1
296+
%l7 = load i8, ptr %p7, align 1
297+
%a0 = add i8 %l0, 1
298+
%a1 = add i8 %l1, 2
299+
%a2 = add i8 %l2, 3
300+
%a3 = add i8 %l3, 4
301+
%a4 = add i8 %l4, 5
302+
%a5 = add i8 %l5, 6
303+
%a6 = add i8 %l6, 7
304+
%a7 = add i8 %l7, 8
305+
store i8 %a0, ptr %p0, align 1
306+
store i8 %a1, ptr %p1, align 1
307+
store i8 %a2, ptr %p2, align 1
308+
store i8 %a3, ptr %p3, align 1
309+
store i8 %a4, ptr %p4, align 1
310+
store i8 %a5, ptr %p5, align 1
311+
store i8 %a6, ptr %p6, align 1
312+
store i8 %a7, ptr %p7, align 1
313+
%i.next = add nuw nsw i64 %i, 1
314+
%cond = icmp slt i64 %i.next, %n
315+
br i1 %cond, label %for.body, label %for.end
316+
317+
for.end:
318+
ret void
319+
}

0 commit comments

Comments
 (0)