Skip to content

Commit 5f73d29

Browse files
committed
[LAA] Add tests showing extra unnecessary runtime checks.
Pre-commit tests for an upcoming patch.
1 parent 09adb53 commit 5f73d29

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
3+
4+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
5+
6+
declare void @llvm.assume(i1)
7+
8+
; FIXME: Currently we check all accesses to the same underlying objects, but
9+
; it is sufficient to check the accesses to %A.
10+
define void @test_dependence_with_non_constant_offset_and_other_accesses_to_noalias_pointers(ptr %A, ptr noalias %B, i64 %off) {
11+
; CHECK-LABEL: 'test_dependence_with_non_constant_offset_and_other_accesses_to_noalias_pointers'
12+
; CHECK-NEXT: loop:
13+
; CHECK-NEXT: Memory dependences are safe with run-time checks
14+
; CHECK-NEXT: Dependences:
15+
; CHECK-NEXT: Run-time memory checks:
16+
; CHECK-NEXT: Check 0:
17+
; CHECK-NEXT: Comparing group ([[GRP1:0x[0-9a-f]+]]):
18+
; CHECK-NEXT: %gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
19+
; CHECK-NEXT: Against group ([[GRP2:0x[0-9a-f]+]]):
20+
; CHECK-NEXT: %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
21+
; CHECK-NEXT: Check 1:
22+
; CHECK-NEXT: Comparing group ([[GRP3:0x[0-9a-f]+]]):
23+
; CHECK-NEXT: %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
24+
; CHECK-NEXT: Against group ([[GRP4:0x[0-9a-f]+]]):
25+
; CHECK-NEXT: %gep.B.1 = getelementptr inbounds i8, ptr %B, i64 %iv.next
26+
; CHECK-NEXT: Grouped accesses:
27+
; CHECK-NEXT: Group [[GRP1]]:
28+
; CHECK-NEXT: (Low: (%off + %A) High: (404 + %off + %A))
29+
; CHECK-NEXT: Member: {(%off + %A),+,4}<nw><%loop>
30+
; CHECK-NEXT: Group [[GRP2]]:
31+
; CHECK-NEXT: (Low: %A High: (101 + %A))
32+
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
33+
; CHECK-NEXT: Group [[GRP3]]:
34+
; CHECK-NEXT: (Low: %B High: (101 + %B))
35+
; CHECK-NEXT: Member: {%B,+,1}<nuw><%loop>
36+
; CHECK-NEXT: Group [[GRP4]]:
37+
; CHECK-NEXT: (Low: (1 + %B)<nuw> High: (102 + %B))
38+
; CHECK-NEXT: Member: {(1 + %B)<nuw>,+,1}<nuw><%loop>
39+
; CHECK-EMPTY:
40+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
41+
; CHECK-NEXT: SCEV assumptions:
42+
; CHECK-EMPTY:
43+
; CHECK-NEXT: Expressions re-written:
44+
;
45+
entry:
46+
%c = icmp sgt i64 %off, 0
47+
call void @llvm.assume(i1 %c)
48+
%A.off = getelementptr inbounds i8, ptr %A, i64 %off
49+
br label %loop
50+
51+
loop:
52+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
53+
%gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
54+
%gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
55+
%l = load i8, ptr %gep.A, align 1
56+
%ext = zext i8 %l to i32
57+
store i32 %ext, ptr %gep.A.400, align 4
58+
%iv.next = add nuw nsw i64 %iv, 1
59+
%gep.B.1 = getelementptr inbounds i8, ptr %B, i64 %iv.next
60+
%l.2 = load i8, ptr %gep.B.1
61+
%gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
62+
store i8 %l.2, ptr %gep.B
63+
%ec = icmp eq i64 %iv, 100
64+
br i1 %ec, label %exit, label %loop
65+
66+
exit:
67+
ret void
68+
}
69+
70+
define void @test_dependence_with_non_constant_offset_and_other_accesses_to_mayalias_pointers(ptr %A, ptr %B, i64 %off) {
71+
; CHECK-LABEL: 'test_dependence_with_non_constant_offset_and_other_accesses_to_mayalias_pointers'
72+
; CHECK-NEXT: loop:
73+
; CHECK-NEXT: Memory dependences are safe with run-time checks
74+
; CHECK-NEXT: Dependences:
75+
; CHECK-NEXT: Run-time memory checks:
76+
; CHECK-NEXT: Check 0:
77+
; CHECK-NEXT: Comparing group ([[GRP5:0x[0-9a-f]+]]):
78+
; CHECK-NEXT: %gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
79+
; CHECK-NEXT: Against group ([[GRP6:0x[0-9a-f]+]]):
80+
; CHECK-NEXT: %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
81+
; CHECK-NEXT: Check 1:
82+
; CHECK-NEXT: Comparing group ([[GRP5]]):
83+
; CHECK-NEXT: %gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
84+
; CHECK-NEXT: Against group ([[GRP7:0x[0-9a-f]+]]):
85+
; CHECK-NEXT: %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
86+
; CHECK-NEXT: Check 2:
87+
; CHECK-NEXT: Comparing group ([[GRP5]]):
88+
; CHECK-NEXT: %gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
89+
; CHECK-NEXT: Against group ([[GRP8:0x[0-9a-f]+]]):
90+
; CHECK-NEXT: %gep.B.1 = getelementptr inbounds i8, ptr %B, i64 %iv.next
91+
; CHECK-NEXT: Check 3:
92+
; CHECK-NEXT: Comparing group ([[GRP6]]):
93+
; CHECK-NEXT: %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
94+
; CHECK-NEXT: Against group ([[GRP7]]):
95+
; CHECK-NEXT: %gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
96+
; CHECK-NEXT: Check 4:
97+
; CHECK-NEXT: Comparing group ([[GRP6]]):
98+
; CHECK-NEXT: %gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
99+
; CHECK-NEXT: Against group ([[GRP8]]):
100+
; CHECK-NEXT: %gep.B.1 = getelementptr inbounds i8, ptr %B, i64 %iv.next
101+
; CHECK-NEXT: Grouped accesses:
102+
; CHECK-NEXT: Group [[GRP5]]:
103+
; CHECK-NEXT: (Low: (%off + %A) High: (404 + %off + %A))
104+
; CHECK-NEXT: Member: {(%off + %A),+,4}<nw><%loop>
105+
; CHECK-NEXT: Group [[GRP6]]:
106+
; CHECK-NEXT: (Low: %B High: (101 + %B))
107+
; CHECK-NEXT: Member: {%B,+,1}<nuw><%loop>
108+
; CHECK-NEXT: Group [[GRP7]]:
109+
; CHECK-NEXT: (Low: %A High: (101 + %A))
110+
; CHECK-NEXT: Member: {%A,+,1}<nuw><%loop>
111+
; CHECK-NEXT: Group [[GRP8]]:
112+
; CHECK-NEXT: (Low: (1 + %B)<nuw> High: (102 + %B))
113+
; CHECK-NEXT: Member: {(1 + %B)<nuw>,+,1}<nuw><%loop>
114+
; CHECK-EMPTY:
115+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
116+
; CHECK-NEXT: SCEV assumptions:
117+
; CHECK-EMPTY:
118+
; CHECK-NEXT: Expressions re-written:
119+
;
120+
entry:
121+
%c = icmp sgt i64 %off, 0
122+
call void @llvm.assume(i1 %c)
123+
%A.off = getelementptr inbounds i8, ptr %A, i64 %off
124+
br label %loop
125+
126+
loop:
127+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
128+
%gep.A.400 = getelementptr inbounds i32, ptr %A.off, i64 %iv
129+
%gep.A = getelementptr inbounds i8, ptr %A, i64 %iv
130+
%l = load i8, ptr %gep.A, align 1
131+
%ext = zext i8 %l to i32
132+
store i32 %ext, ptr %gep.A.400, align 4
133+
%iv.next = add nuw nsw i64 %iv, 1
134+
%gep.B.1 = getelementptr inbounds i8, ptr %B, i64 %iv.next
135+
%l.2 = load i8, ptr %gep.B.1
136+
%gep.B = getelementptr inbounds i8, ptr %B, i64 %iv
137+
store i8 %l.2, ptr %gep.B
138+
%ec = icmp eq i64 %iv, 100
139+
br i1 %ec, label %exit, label %loop
140+
141+
exit:
142+
ret void
143+
}

0 commit comments

Comments
 (0)