1 ; RUN: llc -O3 -march=hexagon < %s | FileCheck %s
3 ; CHECK: loop0(.[[BLOCK:LBB0_[0-9]+]]
5 ; CHECK: = vmemu({{r[0-9]+}}++#1)
6 ; CHECK: = vmemu({{r[0-9]+}}++#1)
7 ; CHECK: = vmemu({{r[0-9]+}}++#1)
8 ; CHECK: = vmemu({{r[0-9]+}}++#1)
11 target triple = "hexagon-unknown--elf"
13 %0 = type { ptr, i32, i32, i32, i32, ptr, ptr, ptr }
16 %3 = type { ptr, i32, i32, i32, i32, i32, i32, ptr, i32, ptr }
17 %4 = type { i64, ptr, [4 x i32], [4 x i32], [4 x i32], i32, i8, i8, [6 x i8] }
19 @g0 = private unnamed_addr constant [5 x i8] c"Load\00", align 1
20 @g1 = private unnamed_addr constant [6 x i8] c"Store\00", align 1
21 @g2 = private unnamed_addr constant [18 x i8] c"Begin realization\00", align 1
22 @g3 = private unnamed_addr constant [16 x i8] c"End realization\00", align 1
23 @g4 = private unnamed_addr constant [8 x i8] c"Produce\00", align 1
24 @g5 = private unnamed_addr constant [7 x i8] c"Update\00", align 1
25 @g6 = private unnamed_addr constant [8 x i8] c"Consume\00", align 1
26 @g7 = private unnamed_addr constant [12 x i8] c"End consume\00", align 1
27 @g8 = private constant [6 x i8] c"input\00", align 32
28 @g9 = private constant [10 x i8] c"dilate3x3\00", align 32
29 @g10 = private constant [2 x %0] [%0 { ptr @g8, i32 1, i32 2, i32 1, i32 8, ptr null, ptr null, ptr null }, %0 { ptr @g9, i32 2, i32 2, i32 1, i32 8, ptr null, ptr null, ptr null }]
30 @g11 = private constant [64 x i8] c"...............................................................\00", align 32
32 ; Function Attrs: nounwind
33 declare ptr @f0(ptr, i32) #0
35 ; Function Attrs: nounwind
36 declare void @f1(ptr, ptr) #0
38 ; Function Attrs: nounwind
39 declare void @f2(ptr, ptr) #0
41 ; Function Attrs: nounwind
42 declare i32 @f3(ptr, ptr) #0
44 ; Function Attrs: nounwind
47 ; Function Attrs: nounwind
50 ; Function Attrs: nounwind
51 define i32 @f6(ptr noalias nocapture readonly %a0, ptr noalias nocapture readonly %a1) #0 {
53 %v0 = getelementptr inbounds %4, ptr %a0, i32 0, i32 1
54 %v1 = load ptr, ptr %v0, align 4
55 %v2 = getelementptr inbounds %4, ptr %a0, i32 0, i32 3, i32 1
56 %v3 = load i32, ptr %v2, align 4
57 %v4 = getelementptr inbounds %4, ptr %a0, i32 0, i32 4, i32 0
58 %v5 = load i32, ptr %v4, align 4
59 %v6 = getelementptr inbounds %4, ptr %a0, i32 0, i32 4, i32 1
60 %v7 = load i32, ptr %v6, align 4
61 %v8 = getelementptr inbounds %4, ptr %a1, i32 0, i32 1
62 %v9 = load ptr, ptr %v8, align 4
63 %v10 = getelementptr inbounds %4, ptr %a1, i32 0, i32 2, i32 0
64 %v11 = load i32, ptr %v10, align 4
65 %v12 = getelementptr inbounds %4, ptr %a1, i32 0, i32 3, i32 1
66 %v13 = load i32, ptr %v12, align 4
67 %v14 = getelementptr inbounds %4, ptr %a1, i32 0, i32 4, i32 0
68 %v15 = load i32, ptr %v14, align 4
69 %v16 = getelementptr inbounds %4, ptr %a1, i32 0, i32 4, i32 1
70 %v17 = load i32, ptr %v16, align 4
71 %v18 = getelementptr inbounds %4, ptr %a1, i32 0, i32 2, i32 1
72 %v19 = load i32, ptr %v18, align 4
73 %v20 = add nsw i32 %v19, %v17
74 %v21 = icmp sgt i32 %v19, 0
75 br i1 %v21, label %b1, label %b11, !prof !3
78 %v22 = ashr i32 %v11, 7
79 %v23 = icmp slt i32 %v22, 0
80 %v24 = select i1 %v23, i32 0, i32 %v22
81 %v25 = icmp sgt i32 %v24, 0
82 br i1 %v25, label %b5, label %b7, !prof !3
84 b2: ; preds = %b5, %b2
85 %v26 = phi i32 [ %v90, %b2 ], [ 0, %b5 ]
86 %v27 = mul nsw i32 %v7, %v3
87 %v28 = add nsw i32 %v27, %v5
88 %v29 = shl nsw i32 %v26, 7
89 %v30 = add nsw i32 %v29, %v15
90 %v31 = add nsw i32 %v150, -1
91 %v32 = mul nsw i32 %v31, %v3
92 %v33 = mul nsw i32 %v150, %v3
93 %v34 = add nsw i32 %v150, 1
94 %v35 = mul nsw i32 %v34, %v3
95 %v36 = sub i32 %v32, %v28
96 %v37 = add i32 %v36, %v30
97 %v38 = add nsw i32 %v37, -1
98 %v39 = getelementptr inbounds i8, ptr %v1, i32 %v38
99 %v41 = load <32 x i32>, ptr %v39, align 1, !tbaa !4
100 %v42 = getelementptr inbounds i8, ptr %v1, i32 %v37
101 %v44 = load <32 x i32>, ptr %v42, align 1, !tbaa !4
102 %v45 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v41, <32 x i32> %v44)
103 %v46 = add nsw i32 %v37, 1
104 %v47 = getelementptr inbounds i8, ptr %v1, i32 %v46
105 %v49 = load <32 x i32>, ptr %v47, align 1, !tbaa !4
106 %v50 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v45, <32 x i32> %v49)
107 %v51 = sub i32 %v33, %v28
108 %v52 = add i32 %v51, %v30
109 %v53 = add nsw i32 %v52, -1
110 %v54 = getelementptr inbounds i8, ptr %v1, i32 %v53
111 %v56 = load <32 x i32>, ptr %v54, align 1, !tbaa !4
112 %v57 = getelementptr inbounds i8, ptr %v1, i32 %v52
113 %v59 = load <32 x i32>, ptr %v57, align 1, !tbaa !4
114 %v60 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v56, <32 x i32> %v59)
115 %v61 = add nsw i32 %v52, 1
116 %v62 = getelementptr inbounds i8, ptr %v1, i32 %v61
117 %v64 = load <32 x i32>, ptr %v62, align 1, !tbaa !4
118 %v65 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v60, <32 x i32> %v64)
119 %v66 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v50, <32 x i32> %v65)
120 %v67 = sub i32 %v35, %v28
121 %v68 = add i32 %v67, %v30
122 %v69 = add nsw i32 %v68, -1
123 %v70 = getelementptr inbounds i8, ptr %v1, i32 %v69
124 %v72 = load <32 x i32>, ptr %v70, align 1, !tbaa !4
125 %v73 = getelementptr inbounds i8, ptr %v1, i32 %v68
126 %v75 = load <32 x i32>, ptr %v73, align 1, !tbaa !4
127 %v76 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v72, <32 x i32> %v75)
128 %v77 = add nsw i32 %v68, 1
129 %v78 = getelementptr inbounds i8, ptr %v1, i32 %v77
130 %v80 = load <32 x i32>, ptr %v78, align 1, !tbaa !4
131 %v81 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v76, <32 x i32> %v80)
132 %v82 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v66, <32 x i32> %v81)
133 %v83 = mul nsw i32 %v150, %v13
134 %v84 = mul nsw i32 %v17, %v13
135 %v85 = add i32 %v84, %v15
136 %v86 = sub i32 %v83, %v85
137 %v87 = add i32 %v86, %v30
138 %v88 = getelementptr inbounds i8, ptr %v9, i32 %v87
139 store <32 x i32> %v82, ptr %v88, align 1, !tbaa !7
140 %v90 = add nuw nsw i32 %v26, 1
141 %v91 = icmp eq i32 %v90, %v24
142 br i1 %v91, label %b6, label %b2
144 b3: ; preds = %b6, %b3
145 %v92 = phi i32 [ %v147, %b3 ], [ %v24, %b6 ]
146 %v93 = add nsw i32 %v15, %v11
147 %v94 = sub i32 %v93, %v28
148 %v95 = add i32 %v94, %v32
149 %v96 = add nsw i32 %v95, -129
150 %v97 = getelementptr inbounds i8, ptr %v1, i32 %v96
151 %v99 = load <32 x i32>, ptr %v97, align 1, !tbaa !4
152 %v100 = add nsw i32 %v95, -128
153 %v101 = getelementptr inbounds i8, ptr %v1, i32 %v100
154 %v103 = load <32 x i32>, ptr %v101, align 1, !tbaa !4
155 %v104 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v99, <32 x i32> %v103)
156 %v105 = add nsw i32 %v95, -127
157 %v106 = getelementptr inbounds i8, ptr %v1, i32 %v105
158 %v108 = load <32 x i32>, ptr %v106, align 1, !tbaa !4
159 %v109 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v104, <32 x i32> %v108)
160 %v110 = add i32 %v94, %v33
161 %v111 = add nsw i32 %v110, -129
162 %v112 = getelementptr inbounds i8, ptr %v1, i32 %v111
163 %v114 = load <32 x i32>, ptr %v112, align 1, !tbaa !4
164 %v115 = add nsw i32 %v110, -128
165 %v116 = getelementptr inbounds i8, ptr %v1, i32 %v115
166 %v118 = load <32 x i32>, ptr %v116, align 1, !tbaa !4
167 %v119 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v114, <32 x i32> %v118)
168 %v120 = add nsw i32 %v110, -127
169 %v121 = getelementptr inbounds i8, ptr %v1, i32 %v120
170 %v123 = load <32 x i32>, ptr %v121, align 1, !tbaa !4
171 %v124 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v119, <32 x i32> %v123)
172 %v125 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v109, <32 x i32> %v124)
173 %v126 = add i32 %v94, %v35
174 %v127 = add nsw i32 %v126, -129
175 %v128 = getelementptr inbounds i8, ptr %v1, i32 %v127
176 %v130 = load <32 x i32>, ptr %v128, align 1, !tbaa !4
177 %v131 = add nsw i32 %v126, -128
178 %v132 = getelementptr inbounds i8, ptr %v1, i32 %v131
179 %v134 = load <32 x i32>, ptr %v132, align 1, !tbaa !4
180 %v135 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v130, <32 x i32> %v134)
181 %v136 = add nsw i32 %v126, -127
182 %v137 = getelementptr inbounds i8, ptr %v1, i32 %v136
183 %v139 = load <32 x i32>, ptr %v137, align 1, !tbaa !4
184 %v140 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v135, <32 x i32> %v139)
185 %v141 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v125, <32 x i32> %v140)
186 %v142 = add i32 %v11, -128
187 %v143 = sub i32 %v142, %v84
188 %v144 = add i32 %v143, %v83
189 %v145 = getelementptr inbounds i8, ptr %v9, i32 %v144
190 store <32 x i32> %v141, ptr %v145, align 1, !tbaa !7
191 %v147 = add nuw nsw i32 %v92, 1
192 %v148 = icmp eq i32 %v147, %v152
193 br i1 %v148, label %b4, label %b3
195 b4: ; preds = %b6, %b3
196 %v149 = icmp eq i32 %v34, %v20
197 br i1 %v149, label %b11, label %b5
199 b5: ; preds = %b4, %b1
200 %v150 = phi i32 [ %v34, %b4 ], [ %v17, %b1 ]
204 %v151 = add nsw i32 %v11, 127
205 %v152 = ashr i32 %v151, 7
206 %v153 = icmp slt i32 %v24, %v152
207 br i1 %v153, label %b3, label %b4, !prof !3
210 %v154 = add nsw i32 %v11, 127
211 %v155 = ashr i32 %v154, 7
212 %v156 = icmp slt i32 %v24, %v155
213 br i1 %v156, label %b9, label %b11, !prof !3
215 b8: ; preds = %b9, %b8
216 %v157 = phi i32 [ %v221, %b8 ], [ %v24, %b9 ]
217 %v158 = mul nsw i32 %v7, %v3
218 %v159 = add nsw i32 %v158, %v5
219 %v160 = add nsw i32 %v15, %v11
220 %v161 = add nsw i32 %v223, -1
221 %v162 = mul nsw i32 %v161, %v3
222 %v163 = mul nsw i32 %v223, %v3
223 %v164 = add nsw i32 %v223, 1
224 %v165 = mul nsw i32 %v164, %v3
225 %v166 = sub i32 %v160, %v159
226 %v167 = add i32 %v166, %v162
227 %v168 = add nsw i32 %v167, -129
228 %v169 = getelementptr inbounds i8, ptr %v1, i32 %v168
229 %v171 = load <32 x i32>, ptr %v169, align 1, !tbaa !4
230 %v172 = add nsw i32 %v167, -128
231 %v173 = getelementptr inbounds i8, ptr %v1, i32 %v172
232 %v175 = load <32 x i32>, ptr %v173, align 1, !tbaa !4
233 %v176 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v171, <32 x i32> %v175)
234 %v177 = add nsw i32 %v167, -127
235 %v178 = getelementptr inbounds i8, ptr %v1, i32 %v177
236 %v180 = load <32 x i32>, ptr %v178, align 1, !tbaa !4
237 %v181 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v176, <32 x i32> %v180)
238 %v182 = add i32 %v166, %v163
239 %v183 = add nsw i32 %v182, -129
240 %v184 = getelementptr inbounds i8, ptr %v1, i32 %v183
241 %v186 = load <32 x i32>, ptr %v184, align 1, !tbaa !4
242 %v187 = add nsw i32 %v182, -128
243 %v188 = getelementptr inbounds i8, ptr %v1, i32 %v187
244 %v190 = load <32 x i32>, ptr %v188, align 1, !tbaa !4
245 %v191 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v186, <32 x i32> %v190)
246 %v192 = add nsw i32 %v182, -127
247 %v193 = getelementptr inbounds i8, ptr %v1, i32 %v192
248 %v195 = load <32 x i32>, ptr %v193, align 1, !tbaa !4
249 %v196 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v191, <32 x i32> %v195)
250 %v197 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v181, <32 x i32> %v196)
251 %v198 = add i32 %v166, %v165
252 %v199 = add nsw i32 %v198, -129
253 %v200 = getelementptr inbounds i8, ptr %v1, i32 %v199
254 %v202 = load <32 x i32>, ptr %v200, align 1, !tbaa !4
255 %v203 = add nsw i32 %v198, -128
256 %v204 = getelementptr inbounds i8, ptr %v1, i32 %v203
257 %v206 = load <32 x i32>, ptr %v204, align 1, !tbaa !4
258 %v207 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v202, <32 x i32> %v206)
259 %v208 = add nsw i32 %v198, -127
260 %v209 = getelementptr inbounds i8, ptr %v1, i32 %v208
261 %v211 = load <32 x i32>, ptr %v209, align 1, !tbaa !4
262 %v212 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v207, <32 x i32> %v211)
263 %v213 = tail call <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32> %v197, <32 x i32> %v212)
264 %v214 = mul nsw i32 %v223, %v13
265 %v215 = mul nsw i32 %v17, %v13
266 %v216 = add i32 %v11, -128
267 %v217 = sub i32 %v216, %v215
268 %v218 = add i32 %v217, %v214
269 %v219 = getelementptr inbounds i8, ptr %v9, i32 %v218
270 store <32 x i32> %v213, ptr %v219, align 1, !tbaa !7
271 %v221 = add nuw nsw i32 %v157, 1
272 %v222 = icmp eq i32 %v221, %v155
273 br i1 %v222, label %b10, label %b8
275 b9: ; preds = %b10, %b7
276 %v223 = phi i32 [ %v164, %b10 ], [ %v17, %b7 ]
280 %v224 = icmp eq i32 %v164, %v20
281 br i1 %v224, label %b11, label %b9
283 b11: ; preds = %b10, %b7, %b4, %b0
287 ; Function Attrs: nounwind readnone
288 declare <32 x i32> @llvm.hexagon.V6.vmaxub.128B(<32 x i32>, <32 x i32>) #1
290 ; Function Attrs: nounwind
291 define i32 @f7(ptr noalias nocapture readonly %a0, ptr noalias nocapture readonly %a1) #0 {
293 %v0 = tail call i32 @f6(ptr %a0, ptr %a1) #0
297 ; Function Attrs: nounwind
298 define i32 @f8(ptr nocapture readonly %a0) #0 {
300 %v1 = load ptr, ptr %a0, align 4
301 %v2 = getelementptr ptr, ptr %a0, i32 1
302 %v4 = load ptr, ptr %v2, align 4
303 %v5 = tail call i32 @f7(ptr %v1, ptr %v4)
307 attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvxv60,+hvx-length128b" }
308 attributes #1 = { nounwind readnone }
310 !llvm.module.flags = !{!0, !1, !2}
312 !0 = !{i32 2, !"halide_use_soft_float_abi", i32 0}
313 !1 = !{i32 2, !"halide_mcpu", !"hexagonv60"}
314 !2 = !{i32 2, !"halide_mattrs", !"+hvxv60,+hvx-length64b"}
315 !3 = !{!"branch_weights", i32 1073741824, i32 0}
316 !4 = !{!5, !5, i64 0}
318 !6 = !{!"Halide buffer"}
319 !7 = !{!8, !8, i64 0}
320 !8 = !{!"dilate3x3", !6}