1 ; RUN: opt %loadPolly -basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=false -polly-print-scops -disable-output < %s | FileCheck %s --check-prefix=INNERMOST
2 ; RUN: opt %loadPolly -basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -polly-print-scops -disable-output < %s | FileCheck %s --check-prefix=INNERMOST
3 ; RUN: opt %loadPolly -basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -polly-allow-nonaffine -polly-print-scops -disable-output < %s | FileCheck %s --check-prefix=ALL
5 ; Here we have a non-affine loop (in the context of the loop nest)
6 ; and also a non-affine access (A[k]). While we can always model the
7 ; innermost loop as a SCoP of depth 1, we can overapproximate the
8 ; innermost loop in the whole loop nest and model A[k] as a non-affine
11 ; INNERMOST: Function: f
12 ; INNERMOST-NEXT: Region: %bb15---%bb13
13 ; INNERMOST-NEXT: Max Loop Depth: 1
14 ; INNERMOST-NEXT: Invariant Accesses: {
16 ; INNERMOST-NEXT: Context:
17 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { : 0 <= p_0 <= 1048576 and 0 <= p_1 <= 1024 and 0 <= p_2 <= 1024 }
18 ; INNERMOST-NEXT: Assumed Context:
19 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { : }
20 ; INNERMOST-NEXT: Invalid Context:
21 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { : false }
22 ; INNERMOST: p0: {0,+,{0,+,1}<nuw><nsw><%bb11>}<nuw><nsw><%bb13>
23 ; INNERMOST-NEXT: p1: {0,+,1}<nuw><nsw><%bb11>
24 ; INNERMOST-NEXT: p2: {0,+,1}<nuw><nsw><%bb13>
25 ; INNERMOST-NEXT: Arrays {
26 ; INNERMOST-NEXT: i32 MemRef_A[*]; // Element size 4
27 ; INNERMOST-NEXT: i64 MemRef_indvars_iv_next6; // Element size 8
28 ; INNERMOST-NEXT: i64 MemRef_indvars_iv_next4; // Element size 8
30 ; INNERMOST-NEXT: Arrays (Bounds as pw_affs) {
31 ; INNERMOST-NEXT: i32 MemRef_A[*]; // Element size 4
32 ; INNERMOST-NEXT: i64 MemRef_indvars_iv_next6; // Element size 8
33 ; INNERMOST-NEXT: i64 MemRef_indvars_iv_next4; // Element size 8
35 ; INNERMOST-NEXT: Alias Groups (0):
37 ; INNERMOST-NEXT: Statements {
38 ; INNERMOST-NEXT: Stmt_bb16
39 ; INNERMOST-NEXT: Domain :=
40 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] : 0 <= i0 <= 1023 - p_0 };
41 ; INNERMOST-NEXT: Schedule :=
42 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] -> [0, i0] };
43 ; INNERMOST-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
44 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] -> MemRef_A[p_1] };
45 ; INNERMOST-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
46 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] -> MemRef_A[p_2] };
47 ; INNERMOST-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0]
48 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] -> MemRef_A[p_0 + i0] };
49 ; INNERMOST-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
50 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb16[i0] -> MemRef_A[p_0 + i0] };
51 ; INNERMOST-NEXT: Stmt_bb26
52 ; INNERMOST-NEXT: Domain :=
53 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb26[] : p_0 <= 1024 };
54 ; INNERMOST-NEXT: Schedule :=
55 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb26[] -> [1, 0] };
56 ; INNERMOST-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
57 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb26[] -> MemRef_indvars_iv_next6[] };
58 ; INNERMOST-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
59 ; INNERMOST-NEXT: [p_0, p_1, p_2] -> { Stmt_bb26[] -> MemRef_indvars_iv_next4[] };
63 ; ALL-NEXT: Region: %bb11---%bb29
64 ; ALL-NEXT: Max Loop Depth: 2
65 ; ALL-NEXT: Invariant Accesses: {
69 ; ALL-NEXT: Assumed Context:
71 ; ALL-NEXT: Invalid Context:
72 ; ALL-NEXT: { : false }
74 ; ALL-NEXT: i32 MemRef_A[*]; // Element size 4
76 ; ALL-NEXT: Arrays (Bounds as pw_affs) {
77 ; ALL-NEXT: i32 MemRef_A[*]; // Element size 4
79 ; ALL-NEXT: Alias Groups (0):
81 ; ALL-NEXT: Statements {
82 ; ALL-NEXT: Stmt_bb15__TO__bb25
84 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] : 0 <= i0 <= 1023 and 0 <= i1 <= 1023 };
85 ; ALL-NEXT: Schedule :=
86 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> [i0, i1] };
87 ; ALL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
88 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[i0] };
89 ; ALL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
90 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[i1] };
91 ; ALL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
92 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] };
93 ; ALL-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
94 ; ALL-NEXT: { Stmt_bb15__TO__bb25[i0, i1] -> MemRef_A[o0] };
98 ; for (int i = 0; i < 1024; i++)
99 ; for (int j = 0; j < 1024; j++)
100 ; for (int k = i *j; k < 1024; k++)
101 ; A[k] += A[i] + A[j];
104 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
106 define void @f(ptr %A) {
110 bb11: ; preds = %bb28, %bb
111 %indvars.iv8 = phi i64 [ %indvars.iv.next9, %bb28 ], [ 0, %bb ]
112 %indvars.iv1 = phi i64 [ %indvars.iv.next2, %bb28 ], [ 0, %bb ]
113 %exitcond10 = icmp ne i64 %indvars.iv8, 1024
114 br i1 %exitcond10, label %bb12, label %bb29
116 bb12: ; preds = %bb11
119 bb13: ; preds = %bb26, %bb12
120 %indvars.iv5 = phi i64 [ %indvars.iv.next6, %bb26 ], [ 0, %bb12 ]
121 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %bb26 ], [ 0, %bb12 ]
122 %exitcond7 = icmp ne i64 %indvars.iv5, 1024
123 br i1 %exitcond7, label %bb14, label %bb27
125 bb14: ; preds = %bb13
128 bb15: ; preds = %bb24, %bb14
129 %indvars.iv = phi i64 [ %indvars.iv.next, %bb24 ], [ %indvars.iv3, %bb14 ]
130 %exitcond = icmp ne i64 %indvars.iv, 1024
131 br i1 %exitcond, label %bb16, label %bb25
133 bb16: ; preds = %bb15
134 %tmp = getelementptr inbounds i32, ptr %A, i64 %indvars.iv8
135 %tmp17 = load i32, ptr %tmp, align 4
136 %tmp18 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
137 %tmp19 = load i32, ptr %tmp18, align 4
138 %tmp20 = add nsw i32 %tmp17, %tmp19
139 %tmp21 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
140 %tmp22 = load i32, ptr %tmp21, align 4
141 %tmp23 = add nsw i32 %tmp22, %tmp20
142 store i32 %tmp23, ptr %tmp21, align 4
145 bb24: ; preds = %bb16
146 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
149 bb25: ; preds = %bb15
152 bb26: ; preds = %bb25
153 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
154 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, %indvars.iv1
157 bb27: ; preds = %bb13
160 bb28: ; preds = %bb27
161 %indvars.iv.next9 = add nuw nsw i64 %indvars.iv8, 1
162 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
165 bb29: ; preds = %bb11