llvm-project
166 строк · 6.2 Кб
1; RUN: opt %loadNPMPolly -polly-process-unprofitable=false -polly-allow-nonaffine-loops '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
2;
3; Even if we allow non-affine loops we can only model the outermost loop, all
4; other loops are boxed in non-affine regions. However, the inner loops can be
5; distributed as black-boxes, thus we will recognize the outer loop as profitable.
6;
7; CHECK: Valid Region for Scop: for.cond => for.end.51
8;
9; void f(int *A) {
10; for (int i = 0; i < 100; i++) {
11; // Non-affine
12; for (int j = 0; j < i * i; j++)
13; for (int k = 0; k < i; k++)
14; A[i]++;
15; // Non-affine
16; for (int j = 0; j < i * i; j++)
17; // Non-affine
18; for (int k = 0; k < j; k++)
19; A[i]++;
20; // Non-affine
21; if (A[i])
22; for (int j = 0; j < 100; j++)
23; for (int k = 0; k < j * j; k++)
24; A[i]++;
25; }
26; }
27;
28target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
29
30define void @f(ptr %A) {
31entry:
32br label %for.cond
33
34for.cond: ; preds = %for.inc.49, %entry
35%indvars.iv5 = phi i64 [ %indvars.iv.next6, %for.inc.49 ], [ 0, %entry ]
36%indvars.iv = phi i32 [ %indvars.iv.next, %for.inc.49 ], [ 0, %entry ]
37%exitcond9 = icmp ne i64 %indvars.iv5, 100
38br i1 %exitcond9, label %for.body, label %for.end.51
39
40for.body: ; preds = %for.cond
41br label %for.cond.1
42
43for.cond.1: ; preds = %for.inc.8, %for.body
44%j.0 = phi i32 [ 0, %for.body ], [ %inc9, %for.inc.8 ]
45%tmp = mul nsw i64 %indvars.iv5, %indvars.iv5
46%tmp10 = sext i32 %j.0 to i64
47%cmp2 = icmp slt i64 %tmp10, %tmp
48br i1 %cmp2, label %for.body.3, label %for.end.10
49
50for.body.3: ; preds = %for.cond.1
51br label %for.cond.4
52
53for.cond.4: ; preds = %for.inc, %for.body.3
54%k.0 = phi i32 [ 0, %for.body.3 ], [ %inc7, %for.inc ]
55%exitcond = icmp ne i32 %k.0, %indvars.iv
56br i1 %exitcond, label %for.body.6, label %for.end
57
58for.body.6: ; preds = %for.cond.4
59%arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
60%tmp11 = load i32, ptr %arrayidx, align 4
61%inc = add nsw i32 %tmp11, 1
62store i32 %inc, ptr %arrayidx, align 4
63br label %for.inc
64
65for.inc: ; preds = %for.body.6
66%inc7 = add nuw nsw i32 %k.0, 1
67br label %for.cond.4
68
69for.end: ; preds = %for.cond.4
70br label %for.inc.8
71
72for.inc.8: ; preds = %for.end
73%inc9 = add nuw nsw i32 %j.0, 1
74br label %for.cond.1
75
76for.end.10: ; preds = %for.cond.1
77br label %for.cond.12
78
79for.cond.12: ; preds = %for.inc.26, %for.end.10
80%indvars.iv1 = phi i32 [ %indvars.iv.next2, %for.inc.26 ], [ 0, %for.end.10 ]
81%tmp12 = mul nsw i64 %indvars.iv5, %indvars.iv5
82%tmp13 = sext i32 %indvars.iv1 to i64
83%cmp14 = icmp slt i64 %tmp13, %tmp12
84br i1 %cmp14, label %for.body.15, label %for.end.28
85
86for.body.15: ; preds = %for.cond.12
87br label %for.cond.17
88
89for.cond.17: ; preds = %for.inc.23, %for.body.15
90%k16.0 = phi i32 [ 0, %for.body.15 ], [ %inc24, %for.inc.23 ]
91%exitcond3 = icmp ne i32 %k16.0, %indvars.iv1
92br i1 %exitcond3, label %for.body.19, label %for.end.25
93
94for.body.19: ; preds = %for.cond.17
95%arrayidx21 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
96%tmp14 = load i32, ptr %arrayidx21, align 4
97%inc22 = add nsw i32 %tmp14, 1
98store i32 %inc22, ptr %arrayidx21, align 4
99br label %for.inc.23
100
101for.inc.23: ; preds = %for.body.19
102%inc24 = add nuw nsw i32 %k16.0, 1
103br label %for.cond.17
104
105for.end.25: ; preds = %for.cond.17
106br label %for.inc.26
107
108for.inc.26: ; preds = %for.end.25
109%indvars.iv.next2 = add nuw nsw i32 %indvars.iv1, 1
110br label %for.cond.12
111
112for.end.28: ; preds = %for.cond.12
113%arrayidx30 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
114%tmp15 = load i32, ptr %arrayidx30, align 4
115%tobool = icmp eq i32 %tmp15, 0
116br i1 %tobool, label %if.end, label %if.then
117
118if.then: ; preds = %for.end.28
119br label %for.cond.32
120
121for.cond.32: ; preds = %for.inc.46, %if.then
122%j31.0 = phi i32 [ 0, %if.then ], [ %inc47, %for.inc.46 ]
123%exitcond4 = icmp ne i32 %j31.0, 100
124br i1 %exitcond4, label %for.body.34, label %for.end.48
125
126for.body.34: ; preds = %for.cond.32
127br label %for.cond.36
128
129for.cond.36: ; preds = %for.inc.43, %for.body.34
130%k35.0 = phi i32 [ 0, %for.body.34 ], [ %inc44, %for.inc.43 ]
131%mul37 = mul nsw i32 %j31.0, %j31.0
132%cmp38 = icmp slt i32 %k35.0, %mul37
133br i1 %cmp38, label %for.body.39, label %for.end.45
134
135for.body.39: ; preds = %for.cond.36
136%arrayidx41 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
137%tmp16 = load i32, ptr %arrayidx41, align 4
138%inc42 = add nsw i32 %tmp16, 1
139store i32 %inc42, ptr %arrayidx41, align 4
140br label %for.inc.43
141
142for.inc.43: ; preds = %for.body.39
143%inc44 = add nuw nsw i32 %k35.0, 1
144br label %for.cond.36
145
146for.end.45: ; preds = %for.cond.36
147br label %for.inc.46
148
149for.inc.46: ; preds = %for.end.45
150%inc47 = add nuw nsw i32 %j31.0, 1
151br label %for.cond.32
152
153for.end.48: ; preds = %for.cond.32
154br label %if.end
155
156if.end: ; preds = %for.end.28, %for.end.48
157br label %for.inc.49
158
159for.inc.49: ; preds = %if.end
160%indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
161%indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
162br label %for.cond
163
164for.end.51: ; preds = %for.cond
165ret void
166}
167