1
+ ; RUN: opt < %s -passes=loop-interchange --pass-remarks-missed=loop-interchange -disable-output 2>&1 | FileCheck %s
2
+ ; RUN: opt < %s -passes=loop-interchange --pass-remarks-missed=loop-interchange -loop-interchange-max-meminstr-count=75
3
+ ; -disable-output 2>&1 | FileCheck --check-prefix=CHECK_INSTR_COUNT %s
4
+ target triple = "aarch64-unknown-linux-gnu"
5
+
6
+ @A = dso_local local_unnamed_addr global [2048 x [2048 x i32 ]] zeroinitializer , align 4
7
+ @B = dso_local local_unnamed_addr global [2048 x [2048 x i32 ]] zeroinitializer , align 4
8
+ @C = dso_local local_unnamed_addr global [2048 x [2048 x i32 ]] zeroinitializer , align 4
9
+
10
+ ; CHECK: Number of loads/stores in the loop are more than threshold.
11
+ ; CHECK_INSTR_COUNT-NOT: Number of loads/stores in the loop are more than threshold.
12
+ define dso_local noundef i32 @many_load_stores () {
13
+ br label %1
14
+
15
+ 1 : ; preds = %9, %0
16
+ %2 = phi i32 [ 0 , %0 ], [ %10 , %9 ]
17
+ %3 = icmp slt i32 %2 , 2048
18
+ br i1 %3 , label %5 , label %4
19
+
20
+ 4 : ; preds = %1
21
+ ret i32 0
22
+
23
+ 5 : ; preds = %1
24
+ br label %6
25
+
26
+ 6 : ; preds = %11, %5
27
+ %7 = phi i32 [ 0 , %5 ], [ %208 , %11 ]
28
+ %8 = icmp slt i32 %7 , 85
29
+ br i1 %8 , label %11 , label %9
30
+
31
+ 9 : ; preds = %6
32
+ %10 = add nsw i32 %2 , 1
33
+ br label %1
34
+
35
+ 11 : ; preds = %6
36
+ %12 = sext i32 %2 to i64
37
+ %13 = getelementptr inbounds [2048 x [2048 x i32 ]], [2048 x [2048 x i32 ]]* @B , i64 0 , i64 %12
38
+ %14 = sext i32 %7 to i64
39
+ %15 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %14
40
+ %16 = load i32 , i32* %15 , align 4
41
+ %17 = getelementptr inbounds [2048 x [2048 x i32 ]], [2048 x [2048 x i32 ]]* @C , i64 0 , i64 %12
42
+ %18 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %14
43
+ %19 = load i32 , i32* %18 , align 4
44
+ %20 = add nsw i32 %16 , %19
45
+ %21 = getelementptr inbounds [2048 x [2048 x i32 ]], [2048 x [2048 x i32 ]]* @A , i64 0 , i64 %12
46
+ %22 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %14
47
+ store i32 %20 , i32* %22 , align 4
48
+ %23 = add nsw i32 %7 , 1
49
+ %24 = sext i32 %23 to i64
50
+ %25 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %24
51
+ %26 = load i32 , i32* %25 , align 4
52
+ %27 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %24
53
+ %28 = load i32 , i32* %27 , align 4
54
+ %29 = add nsw i32 %26 , %28
55
+ %30 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %24
56
+ store i32 %29 , i32* %30 , align 4
57
+ %31 = add nsw i32 %23 , 1
58
+ %32 = sext i32 %31 to i64
59
+ %33 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %32
60
+ %34 = load i32 , i32* %33 , align 4
61
+ %35 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %32
62
+ %36 = load i32 , i32* %35 , align 4
63
+ %37 = add nsw i32 %34 , %36
64
+ %38 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %32
65
+ store i32 %37 , i32* %38 , align 4
66
+ %39 = add nsw i32 %31 , 1
67
+ %40 = sext i32 %39 to i64
68
+ %41 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %40
69
+ %42 = load i32 , i32* %41 , align 4
70
+ %43 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %40
71
+ %44 = load i32 , i32* %43 , align 4
72
+ %45 = add nsw i32 %42 , %44
73
+ %46 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %40
74
+ store i32 %45 , i32* %46 , align 4
75
+ %47 = add nsw i32 %39 , 1
76
+ %48 = sext i32 %47 to i64
77
+ %49 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %48
78
+ %50 = load i32 , i32* %49 , align 4
79
+ %51 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %48
80
+ %52 = load i32 , i32* %51 , align 4
81
+ %53 = add nsw i32 %50 , %52
82
+ %54 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %48
83
+ store i32 %53 , i32* %54 , align 4
84
+ %55 = add nsw i32 %47 , 1
85
+ %56 = sext i32 %55 to i64
86
+ %57 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %56
87
+ %58 = load i32 , i32* %57 , align 4
88
+ %59 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %56
89
+ %60 = load i32 , i32* %59 , align 4
90
+ %61 = add nsw i32 %58 , %60
91
+ %62 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %56
92
+ store i32 %61 , i32* %62 , align 4
93
+ %63 = add nsw i32 %55 , 1
94
+ %64 = sext i32 %63 to i64
95
+ %65 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %64
96
+ %66 = load i32 , i32* %65 , align 4
97
+ %67 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %64
98
+ %68 = load i32 , i32* %67 , align 4
99
+ %69 = add nsw i32 %66 , %68
100
+ %70 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %64
101
+ store i32 %69 , i32* %70 , align 4
102
+ %71 = add nsw i32 %63 , 1
103
+ %72 = sext i32 %71 to i64
104
+ %73 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %72
105
+ %74 = load i32 , i32* %73 , align 4
106
+ %75 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %72
107
+ %76 = load i32 , i32* %75 , align 4
108
+ %77 = add nsw i32 %74 , %76
109
+ %78 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %72
110
+ store i32 %77 , i32* %78 , align 4
111
+ %79 = add nsw i32 %71 , 1
112
+ %80 = sext i32 %79 to i64
113
+ %81 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %80
114
+ %82 = load i32 , i32* %81 , align 4
115
+ %83 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %80
116
+ %84 = load i32 , i32* %83 , align 4
117
+ %85 = add nsw i32 %82 , %84
118
+ %86 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %80
119
+ store i32 %85 , i32* %86 , align 4
120
+ %87 = add nsw i32 %79 , 1
121
+ %88 = sext i32 %87 to i64
122
+ %89 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %88
123
+ %90 = load i32 , i32* %89 , align 4
124
+ %91 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %88
125
+ %92 = load i32 , i32* %91 , align 4
126
+ %93 = add nsw i32 %90 , %92
127
+ %94 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %88
128
+ store i32 %93 , i32* %94 , align 4
129
+ %95 = add nsw i32 %87 , 1
130
+ %96 = sext i32 %95 to i64
131
+ %97 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %96
132
+ %98 = load i32 , i32* %97 , align 4
133
+ %99 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %96
134
+ %100 = load i32 , i32* %99 , align 4
135
+ %101 = add nsw i32 %98 , %100
136
+ %102 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %96
137
+ store i32 %101 , i32* %102 , align 4
138
+ %103 = add nsw i32 %95 , 1
139
+ %104 = sext i32 %103 to i64
140
+ %105 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %104
141
+ %106 = load i32 , i32* %105 , align 4
142
+ %107 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %104
143
+ %108 = load i32 , i32* %107 , align 4
144
+ %109 = add nsw i32 %106 , %108
145
+ %110 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %104
146
+ store i32 %109 , i32* %110 , align 4
147
+ %111 = add nsw i32 %103 , 1
148
+ %112 = sext i32 %111 to i64
149
+ %113 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %112
150
+ %114 = load i32 , i32* %113 , align 4
151
+ %115 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %112
152
+ %116 = load i32 , i32* %115 , align 4
153
+ %117 = add nsw i32 %114 , %116
154
+ %118 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %112
155
+ store i32 %117 , i32* %118 , align 4
156
+ %119 = add nsw i32 %111 , 1
157
+ %120 = sext i32 %119 to i64
158
+ %121 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %120
159
+ %122 = load i32 , i32* %121 , align 4
160
+ %123 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %120
161
+ %124 = load i32 , i32* %123 , align 4
162
+ %125 = add nsw i32 %122 , %124
163
+ %126 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %120
164
+ store i32 %125 , i32* %126 , align 4
165
+ %127 = add nsw i32 %119 , 1
166
+ %128 = sext i32 %127 to i64
167
+ %129 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %128
168
+ %130 = load i32 , i32* %129 , align 4
169
+ %131 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %128
170
+ %132 = load i32 , i32* %131 , align 4
171
+ %133 = add nsw i32 %130 , %132
172
+ %134 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %128
173
+ store i32 %133 , i32* %134 , align 4
174
+ %135 = add nsw i32 %127 , 1
175
+ %136 = sext i32 %135 to i64
176
+ %137 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %136
177
+ %138 = load i32 , i32* %137 , align 4
178
+ %139 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %136
179
+ %140 = load i32 , i32* %139 , align 4
180
+ %141 = add nsw i32 %138 , %140
181
+ %142 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %136
182
+ store i32 %141 , i32* %142 , align 4
183
+ %143 = add nsw i32 %135 , 1
184
+ %144 = sext i32 %143 to i64
185
+ %145 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %144
186
+ %146 = load i32 , i32* %145 , align 4
187
+ %147 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %144
188
+ %148 = load i32 , i32* %147 , align 4
189
+ %149 = add nsw i32 %146 , %148
190
+ %150 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %144
191
+ store i32 %149 , i32* %150 , align 4
192
+ %151 = add nsw i32 %143 , 1
193
+ %152 = sext i32 %151 to i64
194
+ %153 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %152
195
+ %154 = load i32 , i32* %153 , align 4
196
+ %155 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %152
197
+ %156 = load i32 , i32* %155 , align 4
198
+ %157 = add nsw i32 %154 , %156
199
+ %158 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %152
200
+ store i32 %157 , i32* %158 , align 4
201
+ %159 = add nsw i32 %151 , 1
202
+ %160 = sext i32 %159 to i64
203
+ %161 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %160
204
+ %162 = load i32 , i32* %161 , align 4
205
+ %163 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %160
206
+ %164 = load i32 , i32* %163 , align 4
207
+ %165 = add nsw i32 %162 , %164
208
+ %166 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %160
209
+ store i32 %165 , i32* %166 , align 4
210
+ %167 = add nsw i32 %159 , 1
211
+ %168 = sext i32 %167 to i64
212
+ %169 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %168
213
+ %170 = load i32 , i32* %169 , align 4
214
+ %171 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %168
215
+ %172 = load i32 , i32* %171 , align 4
216
+ %173 = add nsw i32 %170 , %172
217
+ %174 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %168
218
+ store i32 %173 , i32* %174 , align 4
219
+ %175 = add nsw i32 %167 , 1
220
+ %176 = sext i32 %175 to i64
221
+ %177 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %176
222
+ %178 = load i32 , i32* %177 , align 4
223
+ %179 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %176
224
+ %180 = load i32 , i32* %179 , align 4
225
+ %181 = add nsw i32 %178 , %180
226
+ %182 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %176
227
+ store i32 %181 , i32* %182 , align 4
228
+ %183 = add nsw i32 %175 , 1
229
+ %184 = sext i32 %183 to i64
230
+ %185 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %184
231
+ %186 = load i32 , i32* %185 , align 4
232
+ %187 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %184
233
+ %188 = load i32 , i32* %187 , align 4
234
+ %189 = add nsw i32 %186 , %188
235
+ %190 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %184
236
+ store i32 %189 , i32* %190 , align 4
237
+ %191 = add nsw i32 %183 , 1
238
+ %192 = sext i32 %191 to i64
239
+ %193 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %192
240
+ %194 = load i32 , i32* %193 , align 4
241
+ %195 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %192
242
+ %196 = load i32 , i32* %195 , align 4
243
+ %197 = add nsw i32 %194 , %196
244
+ %198 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %192
245
+ store i32 %197 , i32* %198 , align 4
246
+ %199 = add nsw i32 %191 , 1
247
+ %200 = sext i32 %199 to i64
248
+ %201 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %13 , i64 0 , i64 %200
249
+ %202 = load i32 , i32* %201 , align 4
250
+ %203 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %17 , i64 0 , i64 %200
251
+ %204 = load i32 , i32* %203 , align 4
252
+ %205 = add nsw i32 %202 , %204
253
+ %206 = getelementptr inbounds [2048 x i32 ], [2048 x i32 ]* %21 , i64 0 , i64 %200
254
+ store i32 %205 , i32* %206 , align 4
255
+ %207 = add nsw i32 %199 , 1
256
+ %208 = add nsw i32 %207 , 24
257
+ br label %6
258
+ }
0 commit comments