• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; REQUIRES: asserts
2; RUN: opt < %s -basic-aa -loop-interchange -verify-dom-info -verify-loop-info \
3; RUN:     -S -debug 2>&1 | FileCheck %s
4
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8@D = common global [100 x [100 x [100 x i32]]] zeroinitializer
9
10;; Test for interchange in loop nest greater than 2.
11;;  for(int i=0;i<100;i++)
12;;    for(int j=0;j<100;j++)
13;;      for(int k=0;k<100;k++)
14;;        D[i][k][j] = D[i][k][j]+t;
15
16; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1
17; CHECK: Loops interchanged.
18
19; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0
20; CHECK: Interchanging loops not profitable.
21
22define void @interchange_08(i32 %t){
23entry:
24  br label %for.cond1.preheader
25
26for.cond1.preheader:                              ; preds = %for.inc15, %entry
27  %i.028 = phi i32 [ 0, %entry ], [ %inc16, %for.inc15 ]
28  br label %for.cond4.preheader
29
30for.cond4.preheader:                              ; preds = %for.inc12, %for.cond1.preheader
31  %j.027 = phi i32 [ 0, %for.cond1.preheader ], [ %inc13, %for.inc12 ]
32  br label %for.body6
33
34for.body6:                                        ; preds = %for.body6, %for.cond4.preheader
35  %k.026 = phi i32 [ 0, %for.cond4.preheader ], [ %inc, %for.body6 ]
36  %arrayidx8 = getelementptr inbounds [100 x [100 x [100 x i32]]], [100 x [100 x [100 x i32]]]* @D, i32 0, i32 %i.028, i32 %k.026, i32 %j.027
37  %0 = load i32, i32* %arrayidx8
38  %add = add nsw i32 %0, %t
39  store i32 %add, i32* %arrayidx8
40  %inc = add nuw nsw i32 %k.026, 1
41  %exitcond = icmp eq i32 %inc, 100
42  br i1 %exitcond, label %for.inc12, label %for.body6
43
44for.inc12:                                        ; preds = %for.body6
45  %inc13 = add nuw nsw i32 %j.027, 1
46  %exitcond29 = icmp eq i32 %inc13, 100
47  br i1 %exitcond29, label %for.inc15, label %for.cond4.preheader
48
49for.inc15:                                        ; preds = %for.inc12
50  %inc16 = add nuw nsw i32 %i.028, 1
51  %exitcond30 = icmp eq i32 %inc16, 100
52  br i1 %exitcond30, label %for.end17, label %for.cond1.preheader
53
54for.end17:                                        ; preds = %for.inc15
55  ret void
56}
57