aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/LoopInterchange/inner-indvar-depend-on-outer-indvar-remark.ll
blob: 51fa6469cdbbbf705bf28bbd3dcb315c1e9b1f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
; REQUIRES: asserts
; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info -S -debug 2>&1 | FileCheck %s

@A = common global [100 x [100 x i64]] zeroinitializer
@N = dso_local local_unnamed_addr global i64 100, align 8

;  for(int i=0;i<100;i++)
;    for(int j=0;j<i;j++)
;      A[j][i] = A[j][i]+k;
;
; Inner loop induction variable exit condition depends on the
; outer loop induction variable, i.e., triangular loops.
;
; CHECK: Loop structure not understood by pass
; CHECK: Not interchanging loops. Cannot prove legality.
;
define void @interchange_01(i64 %k) {
entry:
  br label %for1.header

for1.header:
  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]
  br label %for2

for2:
  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]
  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i
  %lv = load i64, ptr %arrayidx5
  %add = add nsw i64 %lv, %k
  store i64 %add, ptr %arrayidx5
  %j.next = add nuw nsw i64 %j, 1
  %exitcond = icmp eq i64 %j, %i
  br i1 %exitcond, label %for1.inc10, label %for2

for1.inc10:
  %i.next = add nuw nsw i64 %i, 1
  %exitcond26 = icmp eq i64 %i, 99
  br i1 %exitcond26, label %for.end12, label %for1.header

for.end12:
  ret void
}


;  for(int i=0;i<100;i++)
;    for(int j=0;j+i<100;j++)
;      A[j][i] = A[j][i]+k;
;
; Inner loop induction variable exit condition depends on the
; outer loop induction variable, i.e., triangular loops.
;
; CHECK: Loop structure not understood by pass
; CHECK: Not interchanging loops. Cannot prove legality.
;
define void @interchange_02(i64 %k) {
entry:
  br label %for1.header

for1.header:
  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]
  br label %for2

for2:
  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]
  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i
  %lv = load i64, ptr %arrayidx5
  %add = add nsw i64 %lv, %k
  store i64 %add, ptr %arrayidx5
  %0 = add nuw nsw i64 %j, %i
  %j.next = add nuw nsw i64 %j, 1
  %exitcond = icmp eq i64 %0, 100
  br i1 %exitcond, label %for1.inc10, label %for2

for1.inc10:
  %i.next = add nuw nsw i64 %i, 1
  %exitcond26 = icmp eq i64 %i, 99
  br i1 %exitcond26, label %for.end12, label %for1.header

for.end12:
  ret void
}

;  for(int i=0;i<100;i++)
;    for(int j=0;i>j;j++)
;      A[j][i] = A[j][i]+k;
;
; Inner loop induction variable exit condition depends on the
; outer loop induction variable, i.e., triangular loops.
; CHECK: Loop structure not understood by pass
; CHECK: Not interchanging loops. Cannot prove legality.
;
define void @interchange_03(i64 %k) {
entry:
  br label %for1.header

for1.header:
  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]
  br label %for2

for2:
  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]
  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i
  %lv = load i64, ptr %arrayidx5
  %add = add nsw i64 %lv, %k
  store i64 %add, ptr %arrayidx5
  %j.next = add nuw nsw i64 %j, 1
  %exitcond = icmp ne i64 %i, %j
  br i1 %exitcond, label %for2, label %for1.inc10

for1.inc10:
  %i.next = add nuw nsw i64 %i, 1
  %exitcond26 = icmp eq i64 %i, 99
  br i1 %exitcond26, label %for.end12, label %for1.header

for.end12:
  ret void
}