1 ; RUN: opt -S %loadPolly -basicaa -polly-dependences -analyze -polly-dependences-analysis-type=value-based < %s | FileCheck %s -check-prefix=VALUE
2 ; RUN: opt -S %loadPolly -basicaa -polly-dependences -analyze -polly-dependences-analysis-type=memory-based < %s | FileCheck %s -check-prefix=MEMORY
3 ; RUN: opt -S %loadPolly -basicaa -polly-dependences -analyze -polly-dependences-analysis-type=value-based -polly-dependences-analysis-level=access-wise < %s | FileCheck %s -check-prefix=VALUE_ACCESS
5 ; VALUE-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'sequential_writes':
6 ; VALUE-NEXT: RAW dependences:
8 ; VALUE-NEXT: WAR dependences:
10 ; VALUE-NEXT: WAW dependences:
11 ; VALUE-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
13 ;VALUE_ACCESS-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'sequential_writes':
14 ;VALUE_ACCESS-NEXT: RAW dependences:
15 ;VALUE_ACCESS-NEXT: { }
16 ;VALUE_ACCESS-NEXT: WAR dependences:
17 ;VALUE_ACCESS-NEXT: { }
18 ;VALUE_ACCESS-NEXT: WAW dependences:
19 ;VALUE_ACCESS-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; [Stmt_S1[i0] -> Stmt_S1_Write0[]] -> [Stmt_S2[i0] -> Stmt_S2_Write0[]] : 0 <= i0 <= 9; Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; [Stmt_S2[i0] -> Stmt_S2_Write0[]] -> [Stmt_S3[i0] -> Stmt_S3_Write0[]] : 0 <= i0 <= 9; [Stmt_S1[i0] -> Stmt_S1_Write0[]] -> [Stmt_S3[i0] -> Stmt_S3_Write0[]] : 10 <= i0 <= 99; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
22 ; VALUE-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'read_after_writes':
23 ; VALUE-NEXT: RAW dependences:
24 ; VALUE-NEXT: { Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
25 ; VALUE-NEXT: WAR dependences:
27 ; VALUE-NEXT: WAW dependences:
28 ; VALUE-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9 }
30 ;VALUE_ACCESS-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'read_after_writes':
31 ;VALUE_ACCESS-NEXT: RAW dependences:
32 ;VALUE_ACCESS-NEXT: { [Stmt_S1[i0] -> Stmt_S1_Write0[]] -> [Stmt_S3[i0] -> Stmt_S3_Read0[]] : 10 <= i0 <= 99; [Stmt_S2[i0] -> Stmt_S2_Write0[]] -> [Stmt_S3[i0] -> Stmt_S3_Read0[]] : 0 <= i0 <= 9; Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
34 ;VALUE_ACCESS-NEXT: WAR dependences:
35 ;VALUE_ACCESS-NEXT: { }
36 ;VALUE_ACCESS-NEXT: WAW dependences:
37 ;VALUE_ACCESS-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; [Stmt_S1[i0] -> Stmt_S1_Write0[]] -> [Stmt_S2[i0] -> Stmt_S2_Write0[]] : 0 <= i0 <= 9 }
39 ; VALUE-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'write_after_read':
40 ; VALUE-NEXT: RAW dependences:
42 ; VALUE-NEXT: WAR dependences:
43 ; VALUE-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
44 ; VALUE-NEXT: WAW dependences:
45 ; VALUE-NEXT: { Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9 }
47 ;VALUE_ACCESS-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'write_after_read':
48 ;VALUE_ACCESS-NEXT: RAW dependences:
49 ;VALUE_ACCESS-NEXT: { }
50 ;VALUE_ACCESS-NEXT: WAR dependences:
51 ;VALUE_ACCESS-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; [Stmt_S1[i0] -> Stmt_S1_Read0[]] -> [Stmt_S2[i0] -> Stmt_S2_Write0[]] : 0 <= i0 <= 9; [Stmt_S1[i0] -> Stmt_S1_Read0[]] -> [Stmt_S3[i0] -> Stmt_S3_Write0[]] : 10 <= i0 <= 99; Stmt_S1[i0] -> Stmt_S3[i0] : 10 <= i0 <= 99 }
52 ;VALUE_ACCESS-NEXT: WAW dependences:
53 ;VALUE_ACCESS-NEXT: { Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; [Stmt_S2[i0] -> Stmt_S2_Write0[]] -> [Stmt_S3[i0] -> Stmt_S3_Write0[]] : 0 <= i0 <= 9 }
55 ; VALUE-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.2' in function 'parametric_offset':
56 ; VALUE-NEXT: RAW dependences:
57 ; VALUE-NEXT: [p] -> { Stmt_S1[i0] -> Stmt_S2[-p + i0] : i0 >= p and 0 <= i0 <= 99 and i0 <= 9 + p }
58 ; VALUE-NEXT: WAR dependences:
59 ; VALUE-NEXT: [p] -> { }
60 ; VALUE-NEXT: WAW dependences:
61 ; VALUE-NEXT: [p] -> { }
63 ;VALUE_ACCESS-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.2' in function 'parametric_offset':
64 ;VALUE_ACCESS-NEXT: RAW dependences:
65 ;VALUE_ACCESS-NEXT: [p] -> { [Stmt_S1[i0] -> Stmt_S1_Write0[]] -> [Stmt_S2[-p + i0] -> Stmt_S2_Read0[]] : i0 >= p and 0 <= i0 <= 99 and i0 <= 9 + p; Stmt_S1[i0] -> Stmt_S2[-p + i0] : i0 >= p and 0 <= i0 <= 99 and i0 <= 9 + p }
66 ;VALUE_ACCESS-NEXT: WAR dependences:
67 ;VALUE_ACCESS-NEXT: [p] -> { }
68 ;VALUE_ACCESS-NEXT: WAW dependences:
69 ;VALUE_ACCESS-NEXT: [p] -> { }
71 ; MEMORY-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'sequential_writes':
72 ; MEMORY-NEXT: RAW dependences:
74 ; MEMORY-NEXT: WAR dependences:
76 ; MEMORY-NEXT: WAW dependences:
77 ; MEMORY-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 0 <= i0 <= 99 }
79 ; MEMORY-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'read_after_writes':
80 ; MEMORY-NEXT: RAW dependences:
81 ; MEMORY-NEXT: { Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 0 <= i0 <= 99 }
82 ; MEMORY-NEXT: WAR dependences:
84 ; MEMORY-NEXT: WAW dependences:
85 ; MEMORY-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9 }
87 ; MEMORY-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.3' in function 'write_after_read':
88 ; MEMORY-NEXT: RAW dependences:
90 ; MEMORY-NEXT: WAR dependences:
91 ; MEMORY-NEXT: { Stmt_S1[i0] -> Stmt_S2[i0] : 0 <= i0 <= 9; Stmt_S1[i0] -> Stmt_S3[i0] : 0 <= i0 <= 99 }
92 ; MEMORY-NEXT: WAW dependences:
93 ; MEMORY-NEXT: { Stmt_S2[i0] -> Stmt_S3[i0] : 0 <= i0 <= 9 }
95 ; MEMORY-LABEL: Printing analysis 'Polly - Calculate dependences' for region: 'S1 => exit.2' in function 'parametric_offset':
96 ; MEMORY-NEXT: RAW dependences:
97 ; MEMORY-NEXT: [p] -> { Stmt_S1[i0] -> Stmt_S2[-p + i0] : i0 >= p and 0 <= i0 <= 99 and i0 <= 9 + p }
98 ; MEMORY-NEXT: WAR dependences:
99 ; MEMORY-NEXT: [p] -> { }
100 ; MEMORY-NEXT: WAW dependences:
101 ; MEMORY-NEXT: [p] -> { }
103 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
105 ; for(i = 0; i < 100; i++ )
108 ; for (i = 0; i < 10; i++ )
111 ; for (i = 0; i < 200; i++ )
114 define void @sequential_writes() {
116 %A = alloca [200 x i32]
120 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %S1 ]
121 %arrayidx.1 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.1
122 store i32 2, i32* %arrayidx.1
123 %indvar.next.1 = add i64 %indvar.1, 1
124 %exitcond.1 = icmp ne i64 %indvar.next.1, 100
125 br i1 %exitcond.1, label %S1, label %exit.1
131 %indvar.2 = phi i64 [ 0, %exit.1 ], [ %indvar.next.2, %S2 ]
132 %arrayidx.2 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.2
133 store i32 5, i32* %arrayidx.2
134 %indvar.next.2 = add i64 %indvar.2, 1
135 %exitcond.2 = icmp ne i64 %indvar.next.2, 10
136 br i1 %exitcond.2, label %S2, label %exit.2
142 %indvar.3 = phi i64 [ 0, %exit.2 ], [ %indvar.next.3, %S3 ]
143 %arrayidx.3 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.3
144 store i32 7, i32* %arrayidx.3
145 %indvar.next.3 = add i64 %indvar.3, 1
146 %exitcond.3 = icmp ne i64 %indvar.next.3, 200
147 br i1 %exitcond.3, label %S3 , label %exit.3
154 ; for(i = 0; i < 100; i++ )
157 ; for (i = 0; i < 10; i++ )
160 ; for (i = 0; i < 200; i++ )
163 define void @read_after_writes() {
165 %A = alloca [200 x i32]
166 %B = alloca [200 x i32]
170 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %S1 ]
171 %arrayidx.1 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.1
172 store i32 2, i32* %arrayidx.1
173 %indvar.next.1 = add i64 %indvar.1, 1
174 %exitcond.1 = icmp ne i64 %indvar.next.1, 100
175 br i1 %exitcond.1, label %S1, label %exit.1
181 %indvar.2 = phi i64 [ 0, %exit.1 ], [ %indvar.next.2, %S2 ]
182 %arrayidx.2 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.2
183 store i32 5, i32* %arrayidx.2
184 %indvar.next.2 = add i64 %indvar.2, 1
185 %exitcond.2 = icmp ne i64 %indvar.next.2, 10
186 br i1 %exitcond.2, label %S2, label %exit.2
192 %indvar.3 = phi i64 [ 0, %exit.2 ], [ %indvar.next.3, %S3 ]
193 %arrayidx.3.a = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.3
194 %arrayidx.3.b = getelementptr [200 x i32], [200 x i32]* %B, i64 0, i64 %indvar.3
195 %val = load i32, i32* %arrayidx.3.a
196 store i32 %val, i32* %arrayidx.3.b
197 %indvar.next.3 = add i64 %indvar.3, 1
198 %exitcond.3 = icmp ne i64 %indvar.next.3, 200
199 br i1 %exitcond.3, label %S3 , label %exit.3
206 ; for(i = 0; i < 100; i++ )
209 ; for (i = 0; i < 10; i++ )
212 ; for (i = 0; i < 200; i++ )
215 define void @write_after_read() {
217 %A = alloca [200 x i32]
218 %B = alloca [200 x i32]
222 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %S1 ]
223 %arrayidx.1.a = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.1
224 %arrayidx.1.b = getelementptr [200 x i32], [200 x i32]* %B, i64 0, i64 %indvar.1
225 %val = load i32, i32* %arrayidx.1.a
226 store i32 %val, i32* %arrayidx.1.b
227 %indvar.next.1 = add i64 %indvar.1, 1
228 %exitcond.1 = icmp ne i64 %indvar.next.1, 100
229 br i1 %exitcond.1, label %S1, label %exit.1
235 %indvar.2 = phi i64 [ 0, %exit.1 ], [ %indvar.next.2, %S2 ]
236 %arrayidx.2 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.2
237 store i32 5, i32* %arrayidx.2
238 %indvar.next.2 = add i64 %indvar.2, 1
239 %exitcond.2 = icmp ne i64 %indvar.next.2, 10
240 br i1 %exitcond.2, label %S2, label %exit.2
246 %indvar.3 = phi i64 [ 0, %exit.2 ], [ %indvar.next.3, %S3 ]
247 %arrayidx.3 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.3
248 store i32 10, i32* %arrayidx.3
249 %indvar.next.3 = add i64 %indvar.3, 1
250 %exitcond.3 = icmp ne i64 %indvar.next.3, 200
251 br i1 %exitcond.3, label %S3 , label %exit.3
258 ; for(i = 0; i < 100; i++ )
261 ; for(i = 0; i < 100; i++ )
262 ; S2: B[i] = A[i + p];
264 define void @parametric_offset(i64 %p) {
266 %A = alloca [200 x i32]
267 %B = alloca [200 x i32]
271 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %S1 ]
272 %arrayidx.1 = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %indvar.1
273 store i32 10, i32* %arrayidx.1
274 %indvar.next.1 = add i64 %indvar.1, 1
275 %exitcond.1 = icmp ne i64 %indvar.next.1, 100
276 br i1 %exitcond.1, label %S1, label %exit.1
282 %indvar.2 = phi i64 [ 0, %exit.1 ], [ %indvar.next.2, %S2 ]
283 %sum = add i64 %indvar.2, %p
284 %arrayidx.2.a = getelementptr [200 x i32], [200 x i32]* %A, i64 0, i64 %sum
285 %arrayidx.2.b = getelementptr [200 x i32], [200 x i32]* %B, i64 0, i64 %indvar.2
286 %val = load i32, i32* %arrayidx.2.a
287 store i32 %val, i32* %arrayidx.2.b
288 %indvar.next.2 = add i64 %indvar.2, 1
289 %exitcond.2 = icmp ne i64 %indvar.next.2, 10
290 br i1 %exitcond.2, label %S2, label %exit.2