1 ; RUN: opt < %s -disable-output -passes="print<da>" 2>&1 | FileCheck %s
3 ; Note: exact results can be achived even if
4 ; "-da-disable-delinearization-checks" is not used
7 ; CHECK: da analyze - none!
8 ; CHECK: da analyze - consistent anti [1 -2]!
9 ; CHECK: da analyze - none!
13 ;; void t1(int a[N][M]) {
14 ;; for (int i = 0; i < N-1; ++i)
15 ;; for (int j = 2; j < M; ++j)
16 ;; a[i][j] = a[i+1][j-2];
19 ;; Note that there is a getelementptr with index 0, make sure we can analyze this case.
20 define void @t1(ptr %a) {
24 for.body: ; preds = %entry, %for.inc11
25 %indvars.iv4 = phi i64 [ 0, %entry ], [ %indvars.iv.next5, %for.inc11 ]
28 for.body4: ; preds = %for.body, %for.body4
29 %indvars.iv = phi i64 [ 2, %for.body ], [ %indvars.iv.next, %for.body4 ]
30 %0 = add nuw nsw i64 %indvars.iv4, 1
31 %1 = add nsw i64 %indvars.iv, -2
32 %arrayidx6 = getelementptr inbounds [2048 x i32], ptr %a, i64 %0, i64 %1
33 %2 = load i32, ptr %arrayidx6, align 4
34 %arrayidx10 = getelementptr inbounds [2048 x i32], ptr %a, i64 %indvars.iv4, i64 %indvars.iv
35 store i32 %2, ptr %arrayidx10, align 4
36 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
37 %exitcond = icmp ne i64 %indvars.iv.next, 2048
38 br i1 %exitcond, label %for.body4, label %for.inc11
40 for.inc11: ; preds = %for.body4
41 %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
42 %exitcond7 = icmp ne i64 %indvars.iv.next5, 1023
43 br i1 %exitcond7, label %for.body, label %for.end13
45 for.end13: ; preds = %for.inc11
50 ; CHECK: da analyze - consistent anti [1 -2]!
52 ;; Similar to @t1 but includes a call with a "returned" arg, make sure we can analyze
55 define void @t2(ptr %a) {
59 for.body: ; preds = %entry, %for.inc11
60 %indvars.iv4 = phi i64 [ 0, %entry ], [ %indvars.iv.next5, %for.inc11 ]
63 for.body4: ; preds = %for.body, %for.body4
64 %indvars.iv = phi i64 [ 2, %for.body ], [ %indvars.iv.next, %for.body4 ]
65 %0 = add nuw nsw i64 %indvars.iv4, 1
66 %1 = add nsw i64 %indvars.iv, -2
67 %arrayidx6 = getelementptr inbounds [2048 x i32], ptr %a, i64 %0, i64 %1
68 %2 = load i32, ptr %arrayidx6, align 4
69 %call = call ptr @func_with_returned_arg(ptr returned %a)
70 %arrayidx10 = getelementptr inbounds [2048 x i32], ptr %call, i64 %indvars.iv4, i64 %indvars.iv
71 store i32 %2, ptr %arrayidx10, align 4
72 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
73 %exitcond = icmp ne i64 %indvars.iv.next, 2048
74 br i1 %exitcond, label %for.body4, label %for.inc11
76 for.inc11: ; preds = %for.body4
77 %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
78 %exitcond7 = icmp ne i64 %indvars.iv.next5, 1023
79 br i1 %exitcond7, label %for.body, label %for.end13
81 for.end13: ; preds = %for.inc11
85 declare ptr @func_with_returned_arg(ptr returned %arg)
88 ; CHECK: da analyze - none!
89 ; CHECK: da analyze - consistent anti [1 -2 0 -3 2]!
90 ; CHECK: da analyze - none!
94 ;; void t2(int a[][N][N][N][M]) {
95 ;; for (int i1 = 0; i1 < N-1; ++i1)
96 ;; for (int i2 = 2; i2 < N; ++i2)
97 ;; for (int i3 = 0; i3 < N; ++i3)
98 ;; for (int i4 = 3; i4 < N; ++i4)
99 ;; for (int i5 = 0; i5 < M-2; ++i5)
100 ;; a[i1][i2][i3][i4][i5] = a[i1+1][i2-2][i3][i4-3][i5+2];
103 define void @t3(ptr %a) {
107 for.body: ; preds = %entry, %for.inc46
108 %indvars.iv18 = phi i64 [ 0, %entry ], [ %indvars.iv.next19, %for.inc46 ]
111 for.body4: ; preds = %for.body, %for.inc43
112 %indvars.iv14 = phi i64 [ 2, %for.body ], [ %indvars.iv.next15, %for.inc43 ]
115 for.body8: ; preds = %for.body4, %for.inc40
116 %indvars.iv11 = phi i64 [ 0, %for.body4 ], [ %indvars.iv.next12, %for.inc40 ]
119 for.body12: ; preds = %for.body8, %for.inc37
120 %indvars.iv7 = phi i64 [ 3, %for.body8 ], [ %indvars.iv.next8, %for.inc37 ]
123 for.body16: ; preds = %for.body12, %for.body16
124 %indvars.iv = phi i64 [ 0, %for.body12 ], [ %indvars.iv.next, %for.body16 ]
125 %0 = add nuw nsw i64 %indvars.iv18, 1
126 %1 = add nsw i64 %indvars.iv14, -2
127 %2 = add nsw i64 %indvars.iv7, -3
128 %3 = add nuw nsw i64 %indvars.iv, 2
129 %arrayidx26 = getelementptr inbounds [1024 x [1024 x [1024 x [2048 x i32]]]], ptr %a, i64 %0, i64 %1, i64 %indvars.iv11, i64 %2, i64 %3
130 %4 = load i32, ptr %arrayidx26, align 4
131 %arrayidx36 = getelementptr inbounds [1024 x [1024 x [1024 x [2048 x i32]]]], ptr %a, i64 %indvars.iv18, i64 %indvars.iv14, i64 %indvars.iv11, i64 %indvars.iv7, i64 %indvars.iv
132 store i32 %4, ptr %arrayidx36, align 4
133 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
134 %exitcond = icmp ne i64 %indvars.iv.next, 2046
135 br i1 %exitcond, label %for.body16, label %for.inc37
137 for.inc37: ; preds = %for.body16
138 %indvars.iv.next8 = add nuw nsw i64 %indvars.iv7, 1
139 %exitcond10 = icmp ne i64 %indvars.iv.next8, 1024
140 br i1 %exitcond10, label %for.body12, label %for.inc40
142 for.inc40: ; preds = %for.inc37
143 %indvars.iv.next12 = add nuw nsw i64 %indvars.iv11, 1
144 %exitcond13 = icmp ne i64 %indvars.iv.next12, 1024
145 br i1 %exitcond13, label %for.body8, label %for.inc43
147 for.inc43: ; preds = %for.inc40
148 %indvars.iv.next15 = add nuw nsw i64 %indvars.iv14, 1
149 %exitcond17 = icmp ne i64 %indvars.iv.next15, 1024
150 br i1 %exitcond17, label %for.body4, label %for.inc46
152 for.inc46: ; preds = %for.inc43
153 %indvars.iv.next19 = add nuw nsw i64 %indvars.iv18, 1
154 %exitcond21 = icmp ne i64 %indvars.iv.next19, 1023
155 br i1 %exitcond21, label %for.body, label %for.end48
157 for.end48: ; preds = %for.inc46