Skip to content

Commit 20d0f80

Browse files
committed
[test] A test case for D146958
This commit introduces a test for the change introduced by the `[SCEV] Do not plant SCEV checks unnecessarily` commit, D146958. Reviewed By: fhahn, david-arm Differential Revision: https://reviews.llvm.org/D146974
1 parent e5b0276 commit 20d0f80

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -S < %s | FileCheck %s
2+
3+
; This test is to ensure that SCEV checks (which are costly performancewise) are
4+
; not generated when appropriate aliasing checks are sufficient.
5+
6+
define void @foo(ptr %pout, ptr %pin, i64 %val0, i64 %val1, i64 %val2) {
7+
; CHECK-LABEL: @foo(
8+
; FIXME: CHECK below needs to be changed to CHECK-NOT to confirm the change.
9+
; CHECK: vector.scevcheck
10+
; CHECK: vector.body
11+
entry:
12+
%0 = getelementptr double, ptr %pin, i64 %val0
13+
br label %loop1.header
14+
15+
loop1.header: ; preds = %loop1.latch, %entry
16+
%i = phi i64 [ %i.next, %loop1.latch ], [ 0, %entry ]
17+
%mul0 = mul nsw i64 %i, %val2
18+
%arrayidx0 = getelementptr inbounds double, ptr %0, i64 %mul0
19+
%mul1 = mul nsw i64 %i, %val1
20+
br label %loop2.header
21+
22+
loop2.header: ; preds = %loop1.header, %loop2.header
23+
%j = phi i64 [ 0, %loop1.header ], [ %j.next, %loop2.header ]
24+
%1 = load double, ptr %arrayidx0, align 8
25+
%arrayidx1 = getelementptr inbounds double, ptr %0, i64 %j
26+
%2 = load double, ptr %arrayidx1, align 8
27+
%sum = fadd contract double %1, %2
28+
%3 = getelementptr double, ptr %pout, i64 %mul1
29+
%arrayidx2 = getelementptr inbounds double, ptr %3, i64 %j
30+
store double %sum, ptr %arrayidx2, align 8
31+
%j.next = add nuw nsw i64 %j, 1
32+
%cmp = icmp slt i64 %j.next, %val1
33+
br i1 %cmp, label %loop2.header, label %loop1.latch
34+
35+
loop1.latch: ; preds = %loop2.header
36+
%i.next = add nuw nsw i64 %i, 1
37+
%exitcond = icmp eq i64 %i.next, %val1
38+
br i1 %exitcond, label %exit, label %loop1.header
39+
40+
exit: ; preds = %loop1.latch
41+
ret void
42+
}
43+
44+
; Similar test to the above but with the %arrayidx0 moved to the loop2.header
45+
46+
define void @bar(ptr %pout, ptr %pin, i64 %val0, i64 %val1, i64 %val2) {
47+
; CHECK-LABEL: @bar(
48+
; FIXME: CHECK below needs to be changed to CHECK-NOT to confirm the change.
49+
; CHECK: vector.scevcheck
50+
; CHECK: vector.body
51+
entry:
52+
%0 = getelementptr double, ptr %pin, i64 %val0
53+
br label %loop1.header
54+
55+
loop1.header: ; preds = %loop1.latch, %entry
56+
%i = phi i64 [ %i.next, %loop1.latch ], [ 0, %entry ]
57+
%mul0 = mul nsw i64 %i, %val2
58+
%mul1 = mul nsw i64 %i, %val1
59+
br label %loop2.header
60+
61+
loop2.header: ; preds = %loop1.header, %loop2.header
62+
%j = phi i64 [ 0, %loop1.header ], [ %j.next, %loop2.header ]
63+
%arrayidx0 = getelementptr inbounds double, ptr %0, i64 %mul0
64+
%1 = load double, ptr %arrayidx0, align 8
65+
%arrayidx1 = getelementptr inbounds double, ptr %0, i64 %j
66+
%2 = load double, ptr %arrayidx1, align 8
67+
%sum = fadd contract double %1, %2
68+
%3 = getelementptr double, ptr %pout, i64 %mul1
69+
%arrayidx2 = getelementptr inbounds double, ptr %3, i64 %j
70+
store double %sum, ptr %arrayidx2, align 8
71+
%j.next = add nuw nsw i64 %j, 1
72+
%cmp = icmp slt i64 %j.next, %val1
73+
br i1 %cmp, label %loop2.header, label %loop1.latch
74+
75+
loop1.latch: ; preds = %loop2.header
76+
%i.next = add nuw nsw i64 %i, 1
77+
%exitcond = icmp eq i64 %i.next, %val1
78+
br i1 %exitcond, label %exit, label %loop1.header
79+
80+
exit: ; preds = %loop1.latch
81+
ret void
82+
}

0 commit comments

Comments
 (0)