Skip to content

Commit 606a934

Browse files
committed
[LAA] Add test cases where evaluating AddRecs at symbolic max BTC wraps.
The underlying issue was discovered by an assert added in a800533 by a test case provided by @mstorsjo.
1 parent 926f097 commit 606a934

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
3+
4+
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
5+
6+
; FIXME: Start == End for access group with AddRec.
7+
define void @runtime_checks_with_symbolic_max_btc_neg_1(ptr %P, ptr %S, i32 %x, i32 %y) {
8+
; CHECK-LABEL: 'runtime_checks_with_symbolic_max_btc_neg_1'
9+
; CHECK-NEXT: loop:
10+
; CHECK-NEXT: Memory dependences are safe with run-time checks
11+
; CHECK-NEXT: Dependences:
12+
; CHECK-NEXT: Run-time memory checks:
13+
; CHECK-NEXT: Check 0:
14+
; CHECK-NEXT: Comparing group ([[GRP1:0x[0-9a-f]+]]):
15+
; CHECK-NEXT: %gep.iv = getelementptr inbounds i32, ptr %P, i32 %iv
16+
; CHECK-NEXT: Against group ([[GRP2:0x[0-9a-f]+]]):
17+
; CHECK-NEXT: ptr %S
18+
; CHECK-NEXT: Grouped accesses:
19+
; CHECK-NEXT: Group [[GRP1]]:
20+
; CHECK-NEXT: (Low: ((4 * %y) + %P) High: ((4 * %y) + %P))
21+
; CHECK-NEXT: Member: {((4 * %y) + %P),+,4}<%loop>
22+
; CHECK-NEXT: Group [[GRP2]]:
23+
; CHECK-NEXT: (Low: %S High: (4 + %S))
24+
; CHECK-NEXT: Member: %S
25+
; CHECK-EMPTY:
26+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
27+
; CHECK-NEXT: SCEV assumptions:
28+
; CHECK-EMPTY:
29+
; CHECK-NEXT: Expressions re-written:
30+
;
31+
entry:
32+
br label %loop
33+
34+
loop:
35+
%iv = phi i32 [ %y, %entry ], [ %iv.next, %loop ]
36+
%gep.iv = getelementptr inbounds i32, ptr %P, i32 %iv
37+
%l = load i32, ptr %S
38+
store i32 %l, ptr %gep.iv, align 4
39+
%iv.next = add nsw i32 %iv, 1
40+
%c.2 = icmp slt i32 %iv.next, %l
41+
br i1 %c.2, label %loop, label %exit
42+
43+
exit:
44+
ret void
45+
}
46+
47+
; FIXME: Start > End for access group with AddRec.
48+
define void @runtime_check_with_symbolic_max_btc_neg_2(ptr %P, ptr %S, i32 %x, i32 %y) {
49+
; CHECK-LABEL: 'runtime_check_with_symbolic_max_btc_neg_2'
50+
; CHECK-NEXT: loop:
51+
; CHECK-NEXT: Memory dependences are safe with run-time checks
52+
; CHECK-NEXT: Dependences:
53+
; CHECK-NEXT: Run-time memory checks:
54+
; CHECK-NEXT: Check 0:
55+
; CHECK-NEXT: Comparing group ([[GRP3:0x[0-9a-f]+]]):
56+
; CHECK-NEXT: %gep.iv = getelementptr inbounds i32, ptr %P, i32 %iv
57+
; CHECK-NEXT: Against group ([[GRP4:0x[0-9a-f]+]]):
58+
; CHECK-NEXT: ptr %S
59+
; CHECK-NEXT: Grouped accesses:
60+
; CHECK-NEXT: Group [[GRP3]]:
61+
; CHECK-NEXT: (Low: ((4 * %y) + %P) High: (-4 + (4 * %y) + %P))
62+
; CHECK-NEXT: Member: {((4 * %y) + %P),+,4}<%loop>
63+
; CHECK-NEXT: Group [[GRP4]]:
64+
; CHECK-NEXT: (Low: %S High: (4 + %S))
65+
; CHECK-NEXT: Member: %S
66+
; CHECK-EMPTY:
67+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
68+
; CHECK-NEXT: SCEV assumptions:
69+
; CHECK-EMPTY:
70+
; CHECK-NEXT: Expressions re-written:
71+
;
72+
entry:
73+
br label %loop
74+
75+
loop:
76+
%iv = phi i32 [ %y, %entry ], [ %iv.next, %loop ]
77+
%gep.iv = getelementptr inbounds i32, ptr %P, i32 %iv
78+
%l = load i32, ptr %S
79+
store i32 %l, ptr %gep.iv, align 4
80+
%iv.next = add nsw i32 %iv, 1
81+
%a = and i32 %l, -2
82+
%c.2 = icmp slt i32 %iv.next, %a
83+
br i1 %c.2, label %loop, label %exit
84+
85+
exit:
86+
ret void
87+
}
88+
89+
define i32 @check_no_dep_via_bounds_compare_symbolic_max_btc_neg_1(ptr %P, i32 %x, i32 %y) {
90+
; CHECK-LABEL: 'check_no_dep_via_bounds_compare_symbolic_max_btc_neg_1'
91+
; CHECK-NEXT: loop:
92+
; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
93+
; CHECK-NEXT: Unknown data dependence.
94+
; CHECK-NEXT: Dependences:
95+
; CHECK-NEXT: Unknown:
96+
; CHECK-NEXT: store i64 0, ptr %gep.iv, align 4 ->
97+
; CHECK-NEXT: %l.2 = load i32, ptr %gep.P.4, align 4
98+
; CHECK-EMPTY:
99+
; CHECK-NEXT: Unknown:
100+
; CHECK-NEXT: %l = load i32, ptr %gep.iv, align 4 ->
101+
; CHECK-NEXT: store i64 0, ptr %gep.iv, align 4
102+
; CHECK-EMPTY:
103+
; CHECK-NEXT: Run-time memory checks:
104+
; CHECK-NEXT: Grouped accesses:
105+
; CHECK-EMPTY:
106+
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
107+
; CHECK-NEXT: SCEV assumptions:
108+
; CHECK-NEXT: {(8 + (8 * %y) + %P),+,8}<%loop> Added Flags: <nusw>
109+
; CHECK-EMPTY:
110+
; CHECK-NEXT: Expressions re-written:
111+
;
112+
entry:
113+
%gep.P.4 = getelementptr inbounds nuw i8, ptr %P, i32 4
114+
%gep.P.8 = getelementptr inbounds nuw i8, ptr %P, i32 8
115+
br label %loop
116+
117+
loop:
118+
%1 = phi i32 [ %x, %entry ], [ %sel, %loop.latch ]
119+
%iv = phi i32 [ %y, %entry ], [ %iv.next, %loop.latch ]
120+
%gep.iv = getelementptr inbounds i64, ptr %gep.P.8, i32 %iv
121+
%l = load i32, ptr %gep.iv, align 4
122+
%c.1 = icmp eq i32 %l, 3
123+
br i1 %c.1, label %loop.latch, label %if.then
124+
125+
if.then: ; preds = %for.body
126+
store i64 0, ptr %gep.iv, align 4
127+
%l.2 = load i32, ptr %gep.P.4
128+
br label %loop.latch
129+
130+
loop.latch:
131+
%sel = phi i32 [ %l.2, %if.then ], [ %1, %loop ]
132+
%iv.next = add nsw i32 %iv, 1
133+
%c.2 = icmp slt i32 %iv.next, %sel
134+
br i1 %c.2, label %loop, label %exit
135+
136+
exit:
137+
%res = phi i32 [ %iv.next, %loop.latch ]
138+
ret i32 %res
139+
}

0 commit comments

Comments
 (0)