1 ; RUN: opt < %s -basic-aa -loop-interchange -cache-line-size=64 -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S \
2 ; RUN: -verify-dom-info -verify-loop-info -verify-loop-lcssa -stats 2>&1
3 ; RUN: FileCheck --input-file=%t --check-prefix=REMARKS %s
5 ; Triply nested loop, should be able to do interchange three times
6 ; to get the ideal access pattern.
7 ; void f(int e[10][10][10], int f[10][10][10]) {
8 ; for (int a = 0; a < 10; a++) {
9 ; for (int b = 0; b < 10; b++) {
10 ; for (int c = 0; c < 10; c++) {
11 ; f[c][b][a] = e[c][b][a];
17 ; REMARKS: --- !Passed
18 ; REMARKS-NEXT: Pass: loop-interchange
19 ; REMARKS-NEXT: Name: Interchanged
20 ; REMARKS-NEXT: Function: pr43326-triply-nested
21 ; REMARKS: --- !Passed
22 ; REMARKS-NEXT: Pass: loop-interchange
23 ; REMARKS-NEXT: Name: Interchanged
24 ; REMARKS-NEXT: Function: pr43326-triply-nested
25 ; REMARKS: --- !Passed
26 ; REMARKS-NEXT: Pass: loop-interchange
27 ; REMARKS-NEXT: Name: Interchanged
28 ; REMARKS-NEXT: Function: pr43326-triply-nested
30 define void @pr43326-triply-nested([10 x [10 x i32]]* %e, [10 x [10 x i32]]* %f) {
32 br label %for.outermost.header
34 for.outermost.header: ; preds = %entry, %for.outermost.latch
35 %indvars.outermost = phi i64 [ 0, %entry ], [ %indvars.outermost.next, %for.outermost.latch ]
36 br label %for.middle.header
38 for.cond.cleanup: ; preds = %for.outermost.latch
41 for.middle.header: ; preds = %for.outermost.header, %for.middle.latch
42 %indvars.middle = phi i64 [ 0, %for.outermost.header ], [ %indvars.middle.next, %for.middle.latch ]
43 br label %for.innermost
45 for.outermost.latch: ; preds = %for.middle.latch
46 %indvars.outermost.next = add nuw nsw i64 %indvars.outermost, 1
47 %exitcond.outermost = icmp ne i64 %indvars.outermost.next, 10
48 br i1 %exitcond.outermost, label %for.outermost.header, label %for.cond.cleanup
50 for.middle.latch: ; preds = %for.innermost
51 %indvars.middle.next = add nuw nsw i64 %indvars.middle, 1
52 %exitcond.middle = icmp ne i64 %indvars.middle.next, 10
53 br i1 %exitcond.middle, label %for.middle.header, label %for.outermost.latch
55 for.innermost: ; preds = %for.middle.header, %for.innermost
56 %indvars.innermost = phi i64 [ 0, %for.middle.header ], [ %indvars.innermost.next, %for.innermost ]
57 %arrayidx12 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %e, i64 %indvars.innermost, i64 %indvars.middle, i64 %indvars.outermost
58 %0 = load i32, i32* %arrayidx12
59 %arrayidx18 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %f, i64 %indvars.innermost, i64 %indvars.middle, i64 %indvars.outermost
60 store i32 %0, i32* %arrayidx18
61 %indvars.innermost.next = add nuw nsw i64 %indvars.innermost, 1
62 %exitcond.innermost = icmp ne i64 %indvars.innermost.next, 10
63 br i1 %exitcond.innermost, label %for.innermost, label %for.middle.latch