2 ; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info \
3 ; RUN: -S -debug 2>&1 | FileCheck %s
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 @D = common global [100 x [100 x [100 x i32]]] zeroinitializer
9 ;; Test for interchange in loop nest greater than 2.
10 ;; for(int i=0;i<100;i++)
11 ;; for(int j=0;j<100;j++)
12 ;; for(int k=0;k<100;k++)
13 ;; D[k][j][i] = D[k][j][i]+t;
15 ; CHECK: Processing InnerLoopId = 2 and OuterLoopId = 1
16 ; CHECK: Loops interchanged.
18 ; CHECK: Processing InnerLoopId = 1 and OuterLoopId = 0
19 ; CHECK: Loops interchanged.
21 define void @interchange_08(i32 %t){
23 br label %for.cond1.preheader
25 for.cond1.preheader: ; preds = %for.inc15, %entry
26 %i.028 = phi i64 [ 0, %entry ], [ %inc16, %for.inc15 ]
27 br label %for.cond4.preheader
29 for.cond4.preheader: ; preds = %for.inc12, %for.cond1.preheader
30 %j.027 = phi i64 [ 0, %for.cond1.preheader ], [ %inc13, %for.inc12 ]
33 for.body6: ; preds = %for.body6, %for.cond4.preheader
34 %k.026 = phi i64 [ 0, %for.cond4.preheader ], [ %inc, %for.body6 ]
35 %arrayidx8 = getelementptr inbounds [100 x [100 x [100 x i32]]], ptr @D, i64 0, i64 %k.026, i64 %j.027, i64 %i.028
36 %0 = load i32, ptr %arrayidx8
37 %add = add nsw i32 %0, %t
38 store i32 %add, ptr %arrayidx8
39 %inc = add nuw nsw i64 %k.026, 1
40 %exitcond = icmp eq i64 %inc, 100
41 br i1 %exitcond, label %for.inc12, label %for.body6
43 for.inc12: ; preds = %for.body6
44 %inc13 = add nuw nsw i64 %j.027, 1
45 %exitcond29 = icmp eq i64 %inc13, 100
46 br i1 %exitcond29, label %for.inc15, label %for.cond4.preheader
48 for.inc15: ; preds = %for.inc12
49 %inc16 = add nuw nsw i64 %i.028, 1
50 %exitcond30 = icmp eq i64 %inc16, 100
51 br i1 %exitcond30, label %for.end17, label %for.cond1.preheader
53 for.end17: ; preds = %for.inc15