1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -force-vector-width=4 -passes=loop-vectorize -mcpu=haswell < %s | FileCheck %s
4 ;; Basic functional tests for uniform loads and stores. These are cases kept
5 ;; deliberately simple (and unoptimized by other passes) to feed the vectorizer
6 ;; with particular input IR.
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 define i32 @uniform_load(ptr align(4) %addr) {
12 ; CHECK-LABEL: @uniform_load(
14 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
16 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
18 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
19 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ADDR:%.*]], align 4
20 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
21 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
22 ; CHECK-NEXT: br i1 [[TMP1]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
23 ; CHECK: middle.block:
24 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
26 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
27 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
29 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
30 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ADDR]], align 4
31 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
32 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
33 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
35 ; CHECK-NEXT: [[LOAD_LCSSA:%.*]] = phi i32 [ [[LOAD]], [[FOR_BODY]] ], [ [[TMP0]], [[MIDDLE_BLOCK]] ]
36 ; CHECK-NEXT: ret i32 [[LOAD_LCSSA]]
42 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
43 %load = load i32, ptr %addr
44 %iv.next = add nuw nsw i64 %iv, 1
45 %exitcond = icmp eq i64 %iv, 4096
46 br i1 %exitcond, label %loopexit, label %for.body
52 define i32 @uniform_load2(ptr align(4) %addr) {
53 ; CHECK-LABEL: @uniform_load2(
55 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
57 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
59 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
60 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP1:%.*]], [[VECTOR_BODY]] ]
61 ; CHECK-NEXT: [[VEC_PHI1:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP2:%.*]], [[VECTOR_BODY]] ]
62 ; CHECK-NEXT: [[VEC_PHI2:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP3:%.*]], [[VECTOR_BODY]] ]
63 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP4:%.*]], [[VECTOR_BODY]] ]
64 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ADDR:%.*]], align 4
65 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT8:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0
66 ; CHECK-NEXT: [[BROADCAST_SPLAT9:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT8]], <4 x i32> poison, <4 x i32> zeroinitializer
67 ; CHECK-NEXT: [[TMP1]] = add <4 x i32> [[VEC_PHI]], [[BROADCAST_SPLAT9]]
68 ; CHECK-NEXT: [[TMP2]] = add <4 x i32> [[VEC_PHI1]], [[BROADCAST_SPLAT9]]
69 ; CHECK-NEXT: [[TMP3]] = add <4 x i32> [[VEC_PHI2]], [[BROADCAST_SPLAT9]]
70 ; CHECK-NEXT: [[TMP4]] = add <4 x i32> [[VEC_PHI3]], [[BROADCAST_SPLAT9]]
71 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
72 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
73 ; CHECK-NEXT: br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]
74 ; CHECK: middle.block:
75 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <4 x i32> [[TMP2]], [[TMP1]]
76 ; CHECK-NEXT: [[BIN_RDX10:%.*]] = add <4 x i32> [[TMP3]], [[BIN_RDX]]
77 ; CHECK-NEXT: [[BIN_RDX11:%.*]] = add <4 x i32> [[TMP4]], [[BIN_RDX10]]
78 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[BIN_RDX11]])
79 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
81 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
82 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ [[TMP6]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ]
83 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
85 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
86 ; CHECK-NEXT: [[ACCUM:%.*]] = phi i32 [ [[ACCUM_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ]
87 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ADDR]], align 4
88 ; CHECK-NEXT: [[ACCUM_NEXT]] = add i32 [[ACCUM]], [[LOAD]]
89 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
90 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
91 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
93 ; CHECK-NEXT: [[ACCUM_NEXT_LCSSA:%.*]] = phi i32 [ [[ACCUM_NEXT]], [[FOR_BODY]] ], [ [[TMP6]], [[MIDDLE_BLOCK]] ]
94 ; CHECK-NEXT: ret i32 [[ACCUM_NEXT_LCSSA]]
100 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
101 %accum = phi i32 [%accum.next, %for.body], [0, %entry]
102 %load = load i32, ptr %addr
103 %accum.next = add i32 %accum, %load
104 %iv.next = add nuw nsw i64 %iv, 1
105 %exitcond = icmp eq i64 %iv, 4096
106 br i1 %exitcond, label %loopexit, label %for.body
112 define i32 @uniform_address(ptr align(4) %addr, i32 %byte_offset) {
113 ; CHECK-LABEL: @uniform_address(
115 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
117 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
118 ; CHECK: vector.body:
119 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
120 ; CHECK-NEXT: [[TMP0:%.*]] = udiv i32 [[BYTE_OFFSET:%.*]], 4
121 ; CHECK-NEXT: [[TMP1:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
122 ; CHECK-NEXT: [[TMP2:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
123 ; CHECK-NEXT: [[TMP3:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
124 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i32, ptr [[ADDR:%.*]], i32 [[TMP0]]
125 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32, ptr [[ADDR]], i32 [[TMP1]]
126 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr i32, ptr [[ADDR]], i32 [[TMP2]]
127 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr i32, ptr [[ADDR]], i32 [[TMP3]]
128 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP4]], align 4
129 ; CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[TMP5]], align 4
130 ; CHECK-NEXT: [[TMP10:%.*]] = load i32, ptr [[TMP6]], align 4
131 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[TMP7]], align 4
132 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
133 ; CHECK-NEXT: [[TMP12:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
134 ; CHECK-NEXT: br i1 [[TMP12]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
135 ; CHECK: middle.block:
136 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
138 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
139 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
141 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
142 ; CHECK-NEXT: [[OFFSET:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
143 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[ADDR]], i32 [[OFFSET]]
144 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[GEP]], align 4
145 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
146 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
147 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP7:![0-9]+]]
149 ; CHECK-NEXT: [[LOAD_LCSSA:%.*]] = phi i32 [ [[LOAD]], [[FOR_BODY]] ], [ [[TMP11]], [[MIDDLE_BLOCK]] ]
150 ; CHECK-NEXT: ret i32 [[LOAD_LCSSA]]
156 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
157 %offset = udiv i32 %byte_offset, 4
158 %gep = getelementptr i32, ptr %addr, i32 %offset
159 %load = load i32, ptr %gep
160 %iv.next = add nuw nsw i64 %iv, 1
161 %exitcond = icmp eq i64 %iv, 4096
162 br i1 %exitcond, label %loopexit, label %for.body
170 define void @uniform_store_uniform_value(ptr align(4) %addr) {
171 ; CHECK-LABEL: @uniform_store_uniform_value(
173 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
175 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
176 ; CHECK: vector.body:
177 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
178 ; CHECK-NEXT: store i32 0, ptr [[ADDR:%.*]], align 4
179 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
180 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
181 ; CHECK-NEXT: br i1 [[TMP0]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]
182 ; CHECK: middle.block:
183 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
185 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
186 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
188 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
189 ; CHECK-NEXT: store i32 0, ptr [[ADDR]], align 4
190 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
191 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
192 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP9:![0-9]+]]
194 ; CHECK-NEXT: ret void
200 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
201 store i32 0, ptr %addr
202 %iv.next = add nuw nsw i64 %iv, 1
203 %exitcond = icmp eq i64 %iv, 4096
204 br i1 %exitcond, label %loopexit, label %for.body
210 define void @uniform_store_varying_value(ptr align(4) %addr) {
211 ; CHECK-LABEL: @uniform_store_varying_value(
213 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
215 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
216 ; CHECK: vector.body:
217 ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
218 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[OFFSET_IDX]] to i32
219 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[TMP0]], 0
220 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP0]], 1
221 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP0]], 2
222 ; CHECK-NEXT: [[TMP4:%.*]] = add i32 [[TMP0]], 3
223 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[TMP0]], 4
224 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP0]], 5
225 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 [[TMP0]], 6
226 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[TMP0]], 7
227 ; CHECK-NEXT: [[TMP9:%.*]] = add i32 [[TMP0]], 8
228 ; CHECK-NEXT: [[TMP10:%.*]] = add i32 [[TMP0]], 9
229 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP0]], 10
230 ; CHECK-NEXT: [[TMP12:%.*]] = add i32 [[TMP0]], 11
231 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP0]], 12
232 ; CHECK-NEXT: [[TMP14:%.*]] = add i32 [[TMP0]], 13
233 ; CHECK-NEXT: [[TMP15:%.*]] = add i32 [[TMP0]], 14
234 ; CHECK-NEXT: [[TMP16:%.*]] = add i32 [[TMP0]], 15
235 ; CHECK-NEXT: store i32 [[TMP16]], ptr [[ADDR:%.*]], align 4
236 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[OFFSET_IDX]], 16
237 ; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
238 ; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]]
239 ; CHECK: middle.block:
240 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
242 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
243 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
245 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
246 ; CHECK-NEXT: [[IV_I32:%.*]] = trunc i64 [[IV]] to i32
247 ; CHECK-NEXT: store i32 [[IV_I32]], ptr [[ADDR]], align 4
248 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
249 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
250 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP11:![0-9]+]]
252 ; CHECK-NEXT: ret void
258 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
259 %iv.i32 = trunc i64 %iv to i32
260 store i32 %iv.i32, ptr %addr
261 %iv.next = add nuw nsw i64 %iv, 1
262 %exitcond = icmp eq i64 %iv, 4096
263 br i1 %exitcond, label %loopexit, label %for.body
269 define void @uniform_rw(ptr align(4) %addr) {
270 ; CHECK-LABEL: @uniform_rw(
272 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
274 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
275 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ADDR:%.*]], align 4
276 ; CHECK-NEXT: [[INC:%.*]] = add i32 [[LOAD]], 1
277 ; CHECK-NEXT: store i32 [[INC]], ptr [[ADDR]], align 4
278 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
279 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
280 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT:%.*]], label [[FOR_BODY]]
282 ; CHECK-NEXT: ret void
288 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
289 %load = load i32, ptr %addr
290 %inc = add i32 %load, 1
291 store i32 %inc, ptr %addr
292 %iv.next = add nuw nsw i64 %iv, 1
293 %exitcond = icmp eq i64 %iv, 4096
294 br i1 %exitcond, label %loopexit, label %for.body
300 define void @uniform_copy(ptr %A, ptr %B) {
301 ; CHECK-LABEL: @uniform_copy(
303 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_MEMCHECK:%.*]]
304 ; CHECK: vector.memcheck:
305 ; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[B:%.*]], i64 4
306 ; CHECK-NEXT: [[UGLYGEP1:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 4
307 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[B]], [[UGLYGEP1]]
308 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[A]], [[UGLYGEP]]
309 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
310 ; CHECK-NEXT: br i1 [[FOUND_CONFLICT]], label [[SCALAR_PH]], label [[VECTOR_PH:%.*]]
312 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
313 ; CHECK: vector.body:
314 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
315 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4, !alias.scope !12
316 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[B]], align 4, !alias.scope !15, !noalias !12
317 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
318 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
319 ; CHECK-NEXT: br i1 [[TMP1]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP17:![0-9]+]]
320 ; CHECK: middle.block:
321 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
323 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ], [ 0, [[VECTOR_MEMCHECK]] ]
324 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
326 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
327 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[A]], align 4
328 ; CHECK-NEXT: store i32 [[LOAD]], ptr [[B]], align 4
329 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
330 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
331 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP18:![0-9]+]]
333 ; CHECK-NEXT: ret void
339 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
340 %load = load i32, ptr %A
341 store i32 %load, ptr %B
342 %iv.next = add nuw nsw i64 %iv, 1
343 %exitcond = icmp eq i64 %iv, 4096
344 br i1 %exitcond, label %loopexit, label %for.body
351 declare void @init(ptr)
353 ;; Count the number of bits set in a bit vector -- key point of relevance is
354 ;; that the byte load is uniform across 8 iterations at a time.
355 ;; TODO: At the moment, this is vectorized with VF=4 and UF=4. The load is
356 ;; considered uniform across VF=4, but should be considered uniform across
358 define i32 @test_count_bits(ptr %test_base) {
359 ; CHECK-LABEL: @test_count_bits(
361 ; CHECK-NEXT: [[ALLOCA:%.*]] = alloca [4096 x i32], align 4
362 ; CHECK-NEXT: call void @init(ptr [[ALLOCA]])
363 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
365 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
366 ; CHECK: vector.body:
367 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
368 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ]
369 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP36:%.*]], [[VECTOR_BODY]] ]
370 ; CHECK-NEXT: [[VEC_PHI4:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP37:%.*]], [[VECTOR_BODY]] ]
371 ; CHECK-NEXT: [[VEC_PHI5:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP38:%.*]], [[VECTOR_BODY]] ]
372 ; CHECK-NEXT: [[VEC_PHI6:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP39:%.*]], [[VECTOR_BODY]] ]
373 ; CHECK-NEXT: [[STEP_ADD:%.*]] = add <4 x i64> [[VEC_IND]], <i64 4, i64 4, i64 4, i64 4>
374 ; CHECK-NEXT: [[STEP_ADD1:%.*]] = add <4 x i64> [[STEP_ADD]], <i64 4, i64 4, i64 4, i64 4>
375 ; CHECK-NEXT: [[STEP_ADD2:%.*]] = add <4 x i64> [[STEP_ADD1]], <i64 4, i64 4, i64 4, i64 4>
376 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0
377 ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[INDEX]], 4
378 ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[INDEX]], 8
379 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[INDEX]], 12
380 ; CHECK-NEXT: [[TMP4:%.*]] = udiv i64 [[TMP0]], 8
381 ; CHECK-NEXT: [[TMP5:%.*]] = udiv i64 [[TMP1]], 8
382 ; CHECK-NEXT: [[TMP6:%.*]] = udiv i64 [[TMP2]], 8
383 ; CHECK-NEXT: [[TMP7:%.*]] = udiv i64 [[TMP3]], 8
384 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i8, ptr [[TEST_BASE:%.*]], i64 [[TMP4]]
385 ; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds i8, ptr [[TEST_BASE]], i64 [[TMP5]]
386 ; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i8, ptr [[TEST_BASE]], i64 [[TMP6]]
387 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds i8, ptr [[TEST_BASE]], i64 [[TMP7]]
388 ; CHECK-NEXT: [[TMP12:%.*]] = load i8, ptr [[TMP8]], align 1
389 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i8> poison, i8 [[TMP12]], i64 0
390 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i8> [[BROADCAST_SPLATINSERT]], <4 x i8> poison, <4 x i32> zeroinitializer
391 ; CHECK-NEXT: [[TMP13:%.*]] = load i8, ptr [[TMP9]], align 1
392 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT7:%.*]] = insertelement <4 x i8> poison, i8 [[TMP13]], i64 0
393 ; CHECK-NEXT: [[BROADCAST_SPLAT8:%.*]] = shufflevector <4 x i8> [[BROADCAST_SPLATINSERT7]], <4 x i8> poison, <4 x i32> zeroinitializer
394 ; CHECK-NEXT: [[TMP14:%.*]] = load i8, ptr [[TMP10]], align 1
395 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT9:%.*]] = insertelement <4 x i8> poison, i8 [[TMP14]], i64 0
396 ; CHECK-NEXT: [[BROADCAST_SPLAT10:%.*]] = shufflevector <4 x i8> [[BROADCAST_SPLATINSERT9]], <4 x i8> poison, <4 x i32> zeroinitializer
397 ; CHECK-NEXT: [[TMP15:%.*]] = load i8, ptr [[TMP11]], align 1
398 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT11:%.*]] = insertelement <4 x i8> poison, i8 [[TMP15]], i64 0
399 ; CHECK-NEXT: [[BROADCAST_SPLAT12:%.*]] = shufflevector <4 x i8> [[BROADCAST_SPLATINSERT11]], <4 x i8> poison, <4 x i32> zeroinitializer
400 ; CHECK-NEXT: [[TMP16:%.*]] = urem <4 x i64> [[VEC_IND]], <i64 8, i64 8, i64 8, i64 8>
401 ; CHECK-NEXT: [[TMP17:%.*]] = urem <4 x i64> [[STEP_ADD]], <i64 8, i64 8, i64 8, i64 8>
402 ; CHECK-NEXT: [[TMP18:%.*]] = urem <4 x i64> [[STEP_ADD1]], <i64 8, i64 8, i64 8, i64 8>
403 ; CHECK-NEXT: [[TMP19:%.*]] = urem <4 x i64> [[STEP_ADD2]], <i64 8, i64 8, i64 8, i64 8>
404 ; CHECK-NEXT: [[TMP20:%.*]] = trunc <4 x i64> [[TMP16]] to <4 x i8>
405 ; CHECK-NEXT: [[TMP21:%.*]] = trunc <4 x i64> [[TMP17]] to <4 x i8>
406 ; CHECK-NEXT: [[TMP22:%.*]] = trunc <4 x i64> [[TMP18]] to <4 x i8>
407 ; CHECK-NEXT: [[TMP23:%.*]] = trunc <4 x i64> [[TMP19]] to <4 x i8>
408 ; CHECK-NEXT: [[TMP24:%.*]] = lshr <4 x i8> [[BROADCAST_SPLAT]], [[TMP20]]
409 ; CHECK-NEXT: [[TMP25:%.*]] = lshr <4 x i8> [[BROADCAST_SPLAT8]], [[TMP21]]
410 ; CHECK-NEXT: [[TMP26:%.*]] = lshr <4 x i8> [[BROADCAST_SPLAT10]], [[TMP22]]
411 ; CHECK-NEXT: [[TMP27:%.*]] = lshr <4 x i8> [[BROADCAST_SPLAT12]], [[TMP23]]
412 ; CHECK-NEXT: [[TMP28:%.*]] = and <4 x i8> [[TMP24]], <i8 1, i8 1, i8 1, i8 1>
413 ; CHECK-NEXT: [[TMP29:%.*]] = and <4 x i8> [[TMP25]], <i8 1, i8 1, i8 1, i8 1>
414 ; CHECK-NEXT: [[TMP30:%.*]] = and <4 x i8> [[TMP26]], <i8 1, i8 1, i8 1, i8 1>
415 ; CHECK-NEXT: [[TMP31:%.*]] = and <4 x i8> [[TMP27]], <i8 1, i8 1, i8 1, i8 1>
416 ; CHECK-NEXT: [[TMP32:%.*]] = zext <4 x i8> [[TMP28]] to <4 x i32>
417 ; CHECK-NEXT: [[TMP33:%.*]] = zext <4 x i8> [[TMP29]] to <4 x i32>
418 ; CHECK-NEXT: [[TMP34:%.*]] = zext <4 x i8> [[TMP30]] to <4 x i32>
419 ; CHECK-NEXT: [[TMP35:%.*]] = zext <4 x i8> [[TMP31]] to <4 x i32>
420 ; CHECK-NEXT: [[TMP36]] = add <4 x i32> [[VEC_PHI]], [[TMP32]]
421 ; CHECK-NEXT: [[TMP37]] = add <4 x i32> [[VEC_PHI4]], [[TMP33]]
422 ; CHECK-NEXT: [[TMP38]] = add <4 x i32> [[VEC_PHI5]], [[TMP34]]
423 ; CHECK-NEXT: [[TMP39]] = add <4 x i32> [[VEC_PHI6]], [[TMP35]]
424 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
425 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <4 x i64> [[STEP_ADD2]], <i64 4, i64 4, i64 4, i64 4>
426 ; CHECK-NEXT: [[TMP40:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
427 ; CHECK-NEXT: br i1 [[TMP40]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP19:![0-9]+]]
428 ; CHECK: middle.block:
429 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <4 x i32> [[TMP37]], [[TMP36]]
430 ; CHECK-NEXT: [[BIN_RDX13:%.*]] = add <4 x i32> [[TMP38]], [[BIN_RDX]]
431 ; CHECK-NEXT: [[BIN_RDX14:%.*]] = add <4 x i32> [[TMP39]], [[BIN_RDX13]]
432 ; CHECK-NEXT: [[TMP41:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[BIN_RDX14]])
433 ; CHECK-NEXT: br i1 true, label [[LOOP_EXIT:%.*]], label [[SCALAR_PH]]
435 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
436 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ [[TMP41]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ]
437 ; CHECK-NEXT: br label [[LOOP:%.*]]
439 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
440 ; CHECK-NEXT: [[ACCUM:%.*]] = phi i32 [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ], [ [[ACCUM_NEXT:%.*]], [[LOOP]] ]
441 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
442 ; CHECK-NEXT: [[BYTE:%.*]] = udiv i64 [[IV]], 8
443 ; CHECK-NEXT: [[TEST_ADDR:%.*]] = getelementptr inbounds i8, ptr [[TEST_BASE]], i64 [[BYTE]]
444 ; CHECK-NEXT: [[EARLYCND:%.*]] = load i8, ptr [[TEST_ADDR]], align 1
445 ; CHECK-NEXT: [[BIT:%.*]] = urem i64 [[IV]], 8
446 ; CHECK-NEXT: [[BIT_TRUNC:%.*]] = trunc i64 [[BIT]] to i8
447 ; CHECK-NEXT: [[MASK:%.*]] = lshr i8 [[EARLYCND]], [[BIT_TRUNC]]
448 ; CHECK-NEXT: [[TEST:%.*]] = and i8 [[MASK]], 1
449 ; CHECK-NEXT: [[VAL:%.*]] = zext i8 [[TEST]] to i32
450 ; CHECK-NEXT: [[ACCUM_NEXT]] = add i32 [[ACCUM]], [[VAL]]
451 ; CHECK-NEXT: [[EXIT:%.*]] = icmp ugt i64 [[IV]], 4094
452 ; CHECK-NEXT: br i1 [[EXIT]], label [[LOOP_EXIT]], label [[LOOP]], !llvm.loop [[LOOP20:![0-9]+]]
454 ; CHECK-NEXT: [[ACCUM_NEXT_LCSSA:%.*]] = phi i32 [ [[ACCUM_NEXT]], [[LOOP]] ], [ [[TMP41]], [[MIDDLE_BLOCK]] ]
455 ; CHECK-NEXT: ret i32 [[ACCUM_NEXT_LCSSA]]
458 %alloca = alloca [4096 x i32]
459 call void @init(ptr %alloca)
462 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
463 %accum = phi i32 [ 0, %entry ], [ %accum.next, %loop ]
464 %iv.next = add i64 %iv, 1
465 %byte = udiv i64 %iv, 8
466 %test_addr = getelementptr inbounds i8, ptr %test_base, i64 %byte
467 %earlycnd = load i8, ptr %test_addr
468 %bit = urem i64 %iv, 8
469 %bit.trunc = trunc i64 %bit to i8
470 %mask = lshr i8 %earlycnd, %bit.trunc
471 %test = and i8 %mask, 1
472 %val = zext i8 %test to i32
473 %accum.next = add i32 %accum, %val
474 %exit = icmp ugt i64 %iv, 4094
475 br i1 %exit, label %loop_exit, label %loop
481 ;; Same as uniform_load, but show that the uniformity analysis can handle
482 ;; pointer operands which are not local to the function.
483 @GAddr = external global i32 align 4
484 define i32 @uniform_load_global() {
485 ; CHECK-LABEL: @uniform_load_global(
487 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
489 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
490 ; CHECK: vector.body:
491 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
492 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP1:%.*]], [[VECTOR_BODY]] ]
493 ; CHECK-NEXT: [[VEC_PHI1:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP2:%.*]], [[VECTOR_BODY]] ]
494 ; CHECK-NEXT: [[VEC_PHI2:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP3:%.*]], [[VECTOR_BODY]] ]
495 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP4:%.*]], [[VECTOR_BODY]] ]
496 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @GAddr, align 4
497 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT8:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0
498 ; CHECK-NEXT: [[BROADCAST_SPLAT9:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT8]], <4 x i32> poison, <4 x i32> zeroinitializer
499 ; CHECK-NEXT: [[TMP1]] = add <4 x i32> [[VEC_PHI]], [[BROADCAST_SPLAT9]]
500 ; CHECK-NEXT: [[TMP2]] = add <4 x i32> [[VEC_PHI1]], [[BROADCAST_SPLAT9]]
501 ; CHECK-NEXT: [[TMP3]] = add <4 x i32> [[VEC_PHI2]], [[BROADCAST_SPLAT9]]
502 ; CHECK-NEXT: [[TMP4]] = add <4 x i32> [[VEC_PHI3]], [[BROADCAST_SPLAT9]]
503 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
504 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
505 ; CHECK-NEXT: br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP21:![0-9]+]]
506 ; CHECK: middle.block:
507 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <4 x i32> [[TMP2]], [[TMP1]]
508 ; CHECK-NEXT: [[BIN_RDX10:%.*]] = add <4 x i32> [[TMP3]], [[BIN_RDX]]
509 ; CHECK-NEXT: [[BIN_RDX11:%.*]] = add <4 x i32> [[TMP4]], [[BIN_RDX10]]
510 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[BIN_RDX11]])
511 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
513 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
514 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ [[TMP6]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ]
515 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
517 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
518 ; CHECK-NEXT: [[ACCUM:%.*]] = phi i32 [ [[ACCUM_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ]
519 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr @GAddr, align 4
520 ; CHECK-NEXT: [[ACCUM_NEXT]] = add i32 [[ACCUM]], [[LOAD]]
521 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
522 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
523 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP22:![0-9]+]]
525 ; CHECK-NEXT: [[ACCUM_NEXT_LCSSA:%.*]] = phi i32 [ [[ACCUM_NEXT]], [[FOR_BODY]] ], [ [[TMP6]], [[MIDDLE_BLOCK]] ]
526 ; CHECK-NEXT: ret i32 [[ACCUM_NEXT_LCSSA]]
532 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
533 %accum = phi i32 [%accum.next, %for.body], [0, %entry]
534 %load = load i32, ptr @GAddr
535 %accum.next = add i32 %accum, %load
536 %iv.next = add nuw nsw i64 %iv, 1
537 %exitcond = icmp eq i64 %iv, 4096
538 br i1 %exitcond, label %loopexit, label %for.body
544 ;; Same as the global case, but using a constexpr
545 define i32 @uniform_load_constexpr() {
546 ; CHECK-LABEL: @uniform_load_constexpr(
548 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
550 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
551 ; CHECK: vector.body:
552 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
553 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP1:%.*]], [[VECTOR_BODY]] ]
554 ; CHECK-NEXT: [[VEC_PHI1:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP2:%.*]], [[VECTOR_BODY]] ]
555 ; CHECK-NEXT: [[VEC_PHI2:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP3:%.*]], [[VECTOR_BODY]] ]
556 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <4 x i32> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP4:%.*]], [[VECTOR_BODY]] ]
557 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr getelementptr (i32, ptr @GAddr, i64 5), align 4
558 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT8:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0]], i64 0
559 ; CHECK-NEXT: [[BROADCAST_SPLAT9:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT8]], <4 x i32> poison, <4 x i32> zeroinitializer
560 ; CHECK-NEXT: [[TMP1]] = add <4 x i32> [[VEC_PHI]], [[BROADCAST_SPLAT9]]
561 ; CHECK-NEXT: [[TMP2]] = add <4 x i32> [[VEC_PHI1]], [[BROADCAST_SPLAT9]]
562 ; CHECK-NEXT: [[TMP3]] = add <4 x i32> [[VEC_PHI2]], [[BROADCAST_SPLAT9]]
563 ; CHECK-NEXT: [[TMP4]] = add <4 x i32> [[VEC_PHI3]], [[BROADCAST_SPLAT9]]
564 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
565 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
566 ; CHECK-NEXT: br i1 [[TMP5]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP23:![0-9]+]]
567 ; CHECK: middle.block:
568 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <4 x i32> [[TMP2]], [[TMP1]]
569 ; CHECK-NEXT: [[BIN_RDX10:%.*]] = add <4 x i32> [[TMP3]], [[BIN_RDX]]
570 ; CHECK-NEXT: [[BIN_RDX11:%.*]] = add <4 x i32> [[TMP4]], [[BIN_RDX10]]
571 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[BIN_RDX11]])
572 ; CHECK-NEXT: br i1 false, label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
574 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
575 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ [[TMP6]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ]
576 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
578 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
579 ; CHECK-NEXT: [[ACCUM:%.*]] = phi i32 [ [[ACCUM_NEXT:%.*]], [[FOR_BODY]] ], [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ]
580 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr getelementptr (i32, ptr @GAddr, i64 5), align 4
581 ; CHECK-NEXT: [[ACCUM_NEXT]] = add i32 [[ACCUM]], [[LOAD]]
582 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
583 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
584 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], !llvm.loop [[LOOP24:![0-9]+]]
586 ; CHECK-NEXT: [[ACCUM_NEXT_LCSSA:%.*]] = phi i32 [ [[ACCUM_NEXT]], [[FOR_BODY]] ], [ [[TMP6]], [[MIDDLE_BLOCK]] ]
587 ; CHECK-NEXT: ret i32 [[ACCUM_NEXT_LCSSA]]
592 for.body: ; preds = %for.body, %entry
593 %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
594 %accum = phi i32 [ %accum.next, %for.body ], [ 0, %entry ]
595 %load = load i32, ptr getelementptr (i32, ptr @GAddr, i64 5), align 4
596 %accum.next = add i32 %accum, %load
597 %iv.next = add nuw nsw i64 %iv, 1
598 %exitcond = icmp eq i64 %iv, 4096
599 br i1 %exitcond, label %loopexit, label %for.body
601 loopexit: ; preds = %for.body