1; RUN: opt %loadPolly -polly-opt-isl -polly-ast -polly-opt-fusion=max -analyze < %s | FileCheck %s
2;
3;
4;    void tf(int C[256][256][256], int A0[256][256][256], int A1[256][256][256]) {
5;      for (int i = 0; i < 256; ++i)
6;        for (int j = 0; j < 256; ++j)
7;          for (int k = 0; k < 256; ++k)
8;            C[i][j][k] += A0[i][j][k];
9;
10;      for (int i = 0; i < 256; ++i)
11;        for (int j = 0; j < 256; ++j)
12;          for (int k = 0; k < 256; ++k)
13;            C[i][j][k] += A1[i][j][k];
14;    }
15;
16; The tile_after_fusion.ll test has two statements in separate loop nests and
17; checks whether they are tiled after being fused when polly-opt-fusion equals
18; "max".
19;
20; CHECK-LABEL: Printing analysis 'Polly - Generate an AST from the SCoP (isl)' for region: 'for.cond => for.end56' in function 'tf':
21; CHECK:       1st level tiling - Tiles
22; CHECK-NEXT:     for (int c0 = 0; c0 <= 7; c0 += 1)
23; CHECK-NEXT:       for (int c1 = 0; c1 <= 7; c1 += 1)
24; CHECK-NEXT:         for (int c2 = 0; c2 <= 7; c2 += 1) {
25; CHECK-NEXT:           // 1st level tiling - Points
26; CHECK-NEXT:           for (int c3 = 0; c3 <= 31; c3 += 1)
27; CHECK-NEXT:             for (int c4 = 0; c4 <= 31; c4 += 1)
28; CHECK-NEXT:               for (int c5 = 0; c5 <= 31; c5 += 1) {
29; CHECK-NEXT:                 Stmt_for_body6(32 * c0 + c3, 32 * c1 + c4, 32 * c2 + c5);
30; CHECK-NEXT:                 Stmt_for_body34(32 * c0 + c3, 32 * c1 + c4, 32 * c2 + c5);
31
32source_filename = "tile_after_fusion.c"
33target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
34
35define void @tf([256 x [256 x i32]]* %C, [256 x [256 x i32]]* %A0, [256 x [256 x i32]]* %A1) {
36entry:
37  br label %for.cond
38
39for.cond:                                         ; preds = %for.inc20, %entry
40  %indvars.iv13 = phi i64 [ %indvars.iv.next14, %for.inc20 ], [ 0, %entry ]
41  %exitcond15 = icmp ne i64 %indvars.iv13, 256
42  br i1 %exitcond15, label %for.body, label %for.end22
43
44for.body:                                         ; preds = %for.cond
45  br label %for.cond1
46
47for.cond1:                                        ; preds = %for.inc17, %for.body
48  %indvars.iv10 = phi i64 [ %indvars.iv.next11, %for.inc17 ], [ 0, %for.body ]
49  %exitcond12 = icmp ne i64 %indvars.iv10, 256
50  br i1 %exitcond12, label %for.body3, label %for.end19
51
52for.body3:                                        ; preds = %for.cond1
53  br label %for.cond4
54
55for.cond4:                                        ; preds = %for.inc, %for.body3
56  %indvars.iv7 = phi i64 [ %indvars.iv.next8, %for.inc ], [ 0, %for.body3 ]
57  %exitcond9 = icmp ne i64 %indvars.iv7, 256
58  br i1 %exitcond9, label %for.body6, label %for.end
59
60for.body6:                                        ; preds = %for.cond4
61  %arrayidx10 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %A0, i64 %indvars.iv13, i64 %indvars.iv10, i64 %indvars.iv7
62  %tmp = load i32, i32* %arrayidx10, align 4
63  %arrayidx16 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %C, i64 %indvars.iv13, i64 %indvars.iv10, i64 %indvars.iv7
64  %tmp16 = load i32, i32* %arrayidx16, align 4
65  %add = add nsw i32 %tmp16, %tmp
66  store i32 %add, i32* %arrayidx16, align 4
67  br label %for.inc
68
69for.inc:                                          ; preds = %for.body6
70  %indvars.iv.next8 = add nuw nsw i64 %indvars.iv7, 1
71  br label %for.cond4
72
73for.end:                                          ; preds = %for.cond4
74  br label %for.inc17
75
76for.inc17:                                        ; preds = %for.end
77  %indvars.iv.next11 = add nuw nsw i64 %indvars.iv10, 1
78  br label %for.cond1
79
80for.end19:                                        ; preds = %for.cond1
81  br label %for.inc20
82
83for.inc20:                                        ; preds = %for.end19
84  %indvars.iv.next14 = add nuw nsw i64 %indvars.iv13, 1
85  br label %for.cond
86
87for.end22:                                        ; preds = %for.cond
88  br label %for.cond24
89
90for.cond24:                                       ; preds = %for.inc54, %for.end22
91  %indvars.iv4 = phi i64 [ %indvars.iv.next5, %for.inc54 ], [ 0, %for.end22 ]
92  %exitcond6 = icmp ne i64 %indvars.iv4, 256
93  br i1 %exitcond6, label %for.body26, label %for.end56
94
95for.body26:                                       ; preds = %for.cond24
96  br label %for.cond28
97
98for.cond28:                                       ; preds = %for.inc51, %for.body26
99  %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc51 ], [ 0, %for.body26 ]
100  %exitcond3 = icmp ne i64 %indvars.iv1, 256
101  br i1 %exitcond3, label %for.body30, label %for.end53
102
103for.body30:                                       ; preds = %for.cond28
104  br label %for.cond32
105
106for.cond32:                                       ; preds = %for.inc48, %for.body30
107  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc48 ], [ 0, %for.body30 ]
108  %exitcond = icmp ne i64 %indvars.iv, 256
109  br i1 %exitcond, label %for.body34, label %for.end50
110
111for.body34:                                       ; preds = %for.cond32
112  %arrayidx40 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %A1, i64 %indvars.iv4, i64 %indvars.iv1, i64 %indvars.iv
113  %tmp17 = load i32, i32* %arrayidx40, align 4
114  %arrayidx46 = getelementptr inbounds [256 x [256 x i32]], [256 x [256 x i32]]* %C, i64 %indvars.iv4, i64 %indvars.iv1, i64 %indvars.iv
115  %tmp18 = load i32, i32* %arrayidx46, align 4
116  %add47 = add nsw i32 %tmp18, %tmp17
117  store i32 %add47, i32* %arrayidx46, align 4
118  br label %for.inc48
119
120for.inc48:                                        ; preds = %for.body34
121  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
122  br label %for.cond32
123
124for.end50:                                        ; preds = %for.cond32
125  br label %for.inc51
126
127for.inc51:                                        ; preds = %for.end50
128  %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
129  br label %for.cond28
130
131for.end53:                                        ; preds = %for.cond28
132  br label %for.inc54
133
134for.inc54:                                        ; preds = %for.end53
135  %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
136  br label %for.cond24
137
138for.end56:                                        ; preds = %for.cond24
139  ret void
140}
141