3 ; RUN: opt -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=2 -debug -disable-output %s 2>&1 | FileCheck %s
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 @a = common global [2048 x i32] zeroinitializer, align 16
8 @b = common global [2048 x i32] zeroinitializer, align 16
9 @c = common global [2048 x i32] zeroinitializer, align 16
12 ; CHECK-LABEL: LV: Checking a loop in 'sink1'
13 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
14 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
15 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
16 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
17 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
20 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
21 ; CHECK-NEXT: No successors
23 ; CHECK-NEXT: vector.ph:
24 ; CHECK-NEXT: Successor(s): vector loop
26 ; CHECK-NEXT: <x1> vector loop: {
27 ; CHECK-NEXT: vector.body:
28 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
29 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
30 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
31 ; CHECK-NEXT: Successor(s): pred.store
33 ; CHECK: <xVFxUF> pred.store: {
34 ; CHECK-NEXT: pred.store.entry:
35 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
36 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
38 ; CHECK: pred.store.if:
39 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
40 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
41 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b>
42 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%lv.b>, ir<10>
43 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, vp<[[STEPS]]
44 ; CHECK-NEXT: REPLICATE ir<%mul> = mul ir<2>, ir<%add>
45 ; CHECK-NEXT: REPLICATE store ir<%mul>, ir<%gep.a>
46 ; CHECK-NEXT: Successor(s): pred.store.continue
48 ; CHECK: pred.store.continue:
49 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
50 ; CHECK-NEXT: No successors
54 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
55 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
56 ; CHECK-NEXT: No successors
59 define void @sink1(i32 %k) {
64 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
65 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
66 %lv.b = load i32, ptr %gep.b, align 4
67 %add = add i32 %lv.b, 10
68 %mul = mul i32 2, %add
69 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %iv
70 store i32 %mul, ptr %gep.a, align 4
71 %iv.next = add i32 %iv, 1
72 %large = icmp sge i32 %iv, 8
73 %exitcond = icmp eq i32 %iv, %k
74 %realexit = or i1 %large, %exitcond
75 br i1 %realexit, label %exit, label %loop
81 ; CHECK-LABEL: LV: Checking a loop in 'sink2'
82 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
83 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
84 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
85 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
86 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
89 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
90 ; CHECK-NEXT: No successors
92 ; CHECK-NEXT: vector.ph:
93 ; CHECK-NEXT: Successor(s): vector loop
95 ; CHECK-NEXT: <x1> vector loop: {
96 ; CHECK-NEXT: vector.body:
97 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
98 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
99 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
100 ; CHECK-NEXT: Successor(s): pred.load
102 ; CHECK: <xVFxUF> pred.load: {
103 ; CHECK-NEXT: pred.load.entry:
104 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
105 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
107 ; CHECK: pred.load.if:
108 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
109 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
110 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b>
111 ; CHECK-NEXT: Successor(s): pred.load.continue
113 ; CHECK: pred.load.continue:
114 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
115 ; CHECK-NEXT: No successors
119 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%iv>, ir<2>
120 ; CHECK-NEXT: Successor(s): pred.store
122 ; CHECK: <xVFxUF> pred.store: {
123 ; CHECK-NEXT: pred.store.entry:
124 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
125 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
127 ; CHECK: pred.store.if:
128 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, ir<%mul>
129 ; CHECK-NEXT: REPLICATE ir<%add> = add vp<[[PRED]]>, ir<10>
130 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep.a>
131 ; CHECK-NEXT: Successor(s): pred.store.continue
133 ; CHECK: pred.store.continue:
134 ; CHECK-NEXT: No successors
138 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
139 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
140 ; CHECK-NEXT: No successors
143 define void @sink2(i32 %k) {
148 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
149 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
150 %lv.b = load i32, ptr %gep.b, align 4
151 %add = add i32 %lv.b, 10
152 %mul = mul i32 %iv, 2
153 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %mul
154 store i32 %add, ptr %gep.a, align 4
155 %iv.next = add i32 %iv, 1
156 %large = icmp sge i32 %iv, 8
157 %exitcond = icmp eq i32 %iv, %k
158 %realexit = or i1 %large, %exitcond
159 br i1 %realexit, label %exit, label %loop
165 ; CHECK-LABEL: LV: Checking a loop in 'sink3'
166 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
167 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
168 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
169 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
170 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
173 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
174 ; CHECK-NEXT: No successors
176 ; CHECK-NEXT: vector.ph:
177 ; CHECK-NEXT: Successor(s): vector loop
179 ; CHECK-NEXT: <x1> vector loop: {
180 ; CHECK-NEXT: vector.body:
181 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
182 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
183 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
184 ; CHECK-NEXT: Successor(s): pred.load
186 ; CHECK: <xVFxUF> pred.load: {
187 ; CHECK-NEXT: pred.load.entry:
188 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
189 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
191 ; CHECK: pred.load.if:
192 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
193 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
194 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b> (S->V)
195 ; CHECK-NEXT: Successor(s): pred.load.continue
197 ; CHECK: pred.load.continue:
198 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
199 ; CHECK-NEXT: No successors
203 ; CHECK-NEXT: WIDEN ir<%add> = add vp<[[PRED]]>, ir<10>
204 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%iv>, ir<%add>
205 ; CHECK-NEXT: Successor(s): pred.store
207 ; CHECK: <xVFxUF> pred.store: {
208 ; CHECK-NEXT: pred.store.entry:
209 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
210 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
212 ; CHECK: pred.store.if:
213 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, ir<%mul>
214 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep.a>
215 ; CHECK-NEXT: Successor(s): pred.store.continue
217 ; CHECK: pred.store.continue:
218 ; CHECK-NEXT: No successors
222 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
223 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
224 ; CHECK-NEXT: No successors
227 define void @sink3(i32 %k) {
232 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
233 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
234 %lv.b = load i32, ptr %gep.b, align 4
235 %add = add i32 %lv.b, 10
236 %mul = mul i32 %iv, %add
237 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %mul
238 store i32 %add, ptr %gep.a, align 4
239 %iv.next = add i32 %iv, 1
240 %large = icmp sge i32 %iv, 8
241 %exitcond = icmp eq i32 %iv, %k
242 %realexit = or i1 %large, %exitcond
243 br i1 %realexit, label %exit, label %loop
249 ; Make sure we do not sink uniform instructions.
250 define void @uniform_gep(i64 %k, ptr noalias %A, ptr noalias %B) {
251 ; CHECK-LABEL: LV: Checking a loop in 'uniform_gep'
252 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
253 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
254 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
255 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
256 ; CHECK-NEXT: Live-in ir<11> = original trip-count
258 ; CHECK-NEXT: vector.ph:
259 ; CHECK-NEXT: Successor(s): vector loop
261 ; CHECK-NEXT: <x1> vector loop: {
262 ; CHECK-NEXT: vector.body:
263 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
264 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 21, %iv.next, ir<1>
265 ; CHECK-NEXT: vp<[[DERIVED_IV:%.+]]> = DERIVED-IV ir<21> + vp<[[CAN_IV]]> * ir<1>
266 ; CHECK-NEXT: EMIT vp<[[WIDE_CAN_IV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
267 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule vp<[[WIDE_CAN_IV]]>, vp<[[BTC]]>
268 ; CHECK-NEXT: CLONE ir<%gep.A.uniform> = getelementptr inbounds ir<%A>, ir<0>
269 ; CHECK-NEXT: CLONE ir<%lv> = load ir<%gep.A.uniform>
270 ; CHECK-NEXT: WIDEN ir<%cmp> = icmp ult ir<%iv>, ir<%k>
271 ; CHECK-NEXT: EMIT vp<[[NOT2:%.+]]> = not ir<%cmp>
272 ; CHECK-NEXT: EMIT vp<[[MASK2:%.+]]> = select vp<[[MASK]]>, vp<[[NOT2]]>, ir<false>
273 ; CHECK-NEXT: Successor(s): pred.store
275 ; CHECK-NEXT: <xVFxUF> pred.store: {
276 ; CHECK-NEXT: pred.store.entry:
277 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK2]]>
278 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
280 ; CHECK-NEXT: pred.store.if:
281 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[DERIVED_IV]]>, ir<1>
282 ; CHECK-NEXT: REPLICATE ir<%gep.B> = getelementptr inbounds ir<%B>, vp<[[STEPS]]>
283 ; CHECK-NEXT: REPLICATE store ir<%lv>, ir<%gep.B>
284 ; CHECK-NEXT: Successor(s): pred.store.continue
286 ; CHECK-NEXT: pred.store.continue:
287 ; CHECK-NEXT: No successors
289 ; CHECK-NEXT: Successor(s): loop.then.0
291 ; CHECK-NEXT: loop.then.0:
292 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
293 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
294 ; CHECK-NEXT: No successors
301 %iv = phi i64 [ 21, %entry ], [ %iv.next, %loop.latch ]
302 %gep.A.uniform = getelementptr inbounds i16, ptr %A, i64 0
303 %gep.B = getelementptr inbounds i16, ptr %B, i64 %iv
304 %lv = load i16, ptr %gep.A.uniform, align 1
305 %cmp = icmp ult i64 %iv, %k
306 br i1 %cmp, label %loop.latch, label %loop.then
309 store i16 %lv, ptr %gep.B, align 1
313 %iv.next = add nsw i64 %iv, 1
314 %cmp179 = icmp slt i64 %iv.next, 32
315 br i1 %cmp179, label %loop, label %exit
320 ; Loop with predicated load.
321 define void @pred_cfg1(i32 %k, i32 %j) {
322 ; CHECK-LABEL: LV: Checking a loop in 'pred_cfg1'
323 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
324 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
325 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
326 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
327 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
330 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
331 ; CHECK-NEXT: No successors
333 ; CHECK-NEXT: vector.ph:
334 ; CHECK-NEXT: Successor(s): vector loop
336 ; CHECK-NEXT: <x1> vector loop: {
337 ; CHECK-NEXT: vector.body:
338 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
339 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
340 ; CHECK-NEXT: EMIT vp<[[MASK1:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
341 ; CHECK-NEXT: WIDEN ir<%c.1> = icmp ult ir<%iv>, ir<%j>
342 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%iv>, ir<10>
343 ; CHECK-NEXT: EMIT vp<[[MASK2:%.+]]> = select vp<[[MASK1]]>, ir<%c.1>, ir<false>
344 ; CHECK-NEXT: Successor(s): pred.load
346 ; CHECK-NEXT: <xVFxUF> pred.load: {
347 ; CHECK-NEXT: pred.load.entry:
348 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK2]]>
349 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
351 ; CHECK-NEXT: pred.load.if:
352 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
353 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
354 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b> (S->V)
355 ; CHECK-NEXT: Successor(s): pred.load.continue
357 ; CHECK-NEXT: pred.load.continue:
358 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
359 ; CHECK-NEXT: No successors
361 ; CHECK-NEXT: Successor(s): then.0.0
363 ; CHECK-NEXT: then.0.0:
364 ; CHECK-NEXT: EMIT vp<[[NOT:%.+]]> = not ir<%c.1>
365 ; CHECK-NEXT: EMIT vp<[[MASK3:%.+]]> = select vp<[[MASK1]]>, vp<[[NOT]]>, ir<false>
366 ; CHECK-NEXT: EMIT vp<[[OR:%.+]]> = or vp<[[MASK2]]>, vp<[[MASK3]]>
367 ; CHECK-NEXT: BLEND ir<%p> = ir<0>/vp<[[MASK3]]> vp<[[PRED]]>/vp<[[MASK2]]>
368 ; CHECK-NEXT: Successor(s): pred.store
370 ; CHECK-NEXT: <xVFxUF> pred.store: {
371 ; CHECK-NEXT: pred.store.entry:
372 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[OR]]>
373 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
375 ; CHECK-NEXT: pred.store.if:
376 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, ir<%mul>
377 ; CHECK-NEXT: REPLICATE store ir<%p>, ir<%gep.a>
378 ; CHECK-NEXT: Successor(s): pred.store.continue
380 ; CHECK-NEXT: pred.store.continue:
381 ; CHECK-NEXT: No successors
383 ; CHECK-NEXT: Successor(s): next.0.1
385 ; CHECK-NEXT: next.0.1:
386 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
387 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
388 ; CHECK-NEXT: No successors
395 %iv = phi i32 [ 0, %entry ], [ %iv.next, %next.0 ]
396 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
397 %c.1 = icmp ult i32 %iv, %j
398 %mul = mul i32 %iv, 10
399 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %mul
400 br i1 %c.1, label %then.0, label %next.0
403 %lv.b = load i32, ptr %gep.b, align 4
407 %p = phi i32 [ 0, %loop ], [ %lv.b, %then.0 ]
408 store i32 %p, ptr %gep.a, align 4
409 %iv.next = add i32 %iv, 1
410 %large = icmp sge i32 %iv, 8
411 %exitcond = icmp eq i32 %iv, %k
412 %realexit = or i1 %large, %exitcond
413 br i1 %realexit, label %exit, label %loop
419 ; Loop with predicated load and store in separate blocks, store depends on
421 define void @pred_cfg2(i32 %k, i32 %j) {
422 ; CHECK-LABEL: LV: Checking a loop in 'pred_cfg2'
423 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
424 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
425 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
426 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
427 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
430 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
431 ; CHECK-NEXT: No successors
433 ; CHECK-NEXT: vector.ph:
434 ; CHECK-NEXT: Successor(s): vector loop
436 ; CHECK-NEXT: <x1> vector loop: {
437 ; CHECK-NEXT: vector.body:
438 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
439 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
440 ; CHECK-NEXT: EMIT vp<[[MASK1:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
441 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%iv>, ir<10>
442 ; CHECK-NEXT: WIDEN ir<%c.0> = icmp ult ir<%iv>, ir<%j>
443 ; CHECK-NEXT: WIDEN ir<%c.1> = icmp ugt ir<%iv>, ir<%j>
444 ; CHECK-NEXT: EMIT vp<[[MASK2:%.+]]> = select vp<[[MASK1]]>, ir<%c.0>, ir<false>
445 ; CHECK-NEXT: Successor(s): pred.load
447 ; CHECK-NEXT: <xVFxUF> pred.load: {
448 ; CHECK-NEXT: pred.load.entry:
449 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK2]]>
450 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
452 ; CHECK-NEXT: pred.load.if:
453 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
454 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
455 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b> (S->V)
456 ; CHECK-NEXT: Successor(s): pred.load.continue
458 ; CHECK-NEXT: pred.load.continue:
459 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
460 ; CHECK-NEXT: No successors
462 ; CHECK-NEXT: Successor(s): then.0.0
464 ; CHECK-NEXT: then.0.0:
465 ; CHECK-NEXT: EMIT vp<[[NOT:%.+]]> = not ir<%c.0>
466 ; CHECK-NEXT: EMIT vp<[[MASK3:%.+]]> = select vp<[[MASK1]]>, vp<[[NOT]]>, ir<false>
467 ; CHECK-NEXT: EMIT vp<[[OR:%.+]]> = or vp<[[MASK2]]>, vp<[[MASK3]]>
468 ; CHECK-NEXT: BLEND ir<%p> = ir<0>/vp<[[MASK3]]> vp<[[PRED]]>/vp<[[MASK2]]>
469 ; CHECK-NEXT: EMIT vp<[[MASK4:%.+]]> = select vp<[[OR]]>, ir<%c.1>, ir<false>
470 ; CHECK-NEXT: Successor(s): pred.store
472 ; CHECK-NEXT: <xVFxUF> pred.store: {
473 ; CHECK-NEXT: pred.store.entry:
474 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK4]]>
475 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
477 ; CHECK-NEXT: pred.store.if:
478 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, ir<%mul>
479 ; CHECK-NEXT: REPLICATE store ir<%p>, ir<%gep.a>
480 ; CHECK-NEXT: Successor(s): pred.store.continue
482 ; CHECK-NEXT: pred.store.continue:
483 ; CHECK-NEXT: No successors
485 ; CHECK-NEXT: Successor(s): then.1.1
487 ; CHECK-NEXT: then.1.1:
488 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
489 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
490 ; CHECK-NEXT: No successors
497 %iv = phi i32 [ 0, %entry ], [ %iv.next, %next.1 ]
498 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
499 %mul = mul i32 %iv, 10
500 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %mul
501 %c.0 = icmp ult i32 %iv, %j
502 %c.1 = icmp ugt i32 %iv, %j
503 br i1 %c.0, label %then.0, label %next.0
506 %lv.b = load i32, ptr %gep.b, align 4
510 %p = phi i32 [ 0, %loop ], [ %lv.b, %then.0 ]
511 br i1 %c.1, label %then.1, label %next.1
514 store i32 %p, ptr %gep.a, align 4
518 %iv.next = add i32 %iv, 1
519 %large = icmp sge i32 %iv, 8
520 %exitcond = icmp eq i32 %iv, %k
521 %realexit = or i1 %large, %exitcond
522 br i1 %realexit, label %exit, label %loop
528 ; Loop with predicated load and store in separate blocks, store does not depend
530 define void @pred_cfg3(i32 %k, i32 %j) {
531 ; CHECK-LABEL: LV: Checking a loop in 'pred_cfg3'
532 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
533 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
534 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
535 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
536 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
539 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
540 ; CHECK-NEXT: No successors
542 ; CHECK-NEXT: vector.ph:
543 ; CHECK-NEXT: Successor(s): vector loop
545 ; CHECK-NEXT: <x1> vector loop: {
546 ; CHECK-NEXT: vector.body:
547 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
548 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
549 ; CHECK-NEXT: EMIT vp<[[MASK1:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
550 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%iv>, ir<10>
551 ; CHECK-NEXT: WIDEN ir<%c.0> = icmp ult ir<%iv>, ir<%j>
552 ; CHECK-NEXT: EMIT vp<[[MASK2:%.+]]> = select vp<[[MASK1:%.+]]>, ir<%c.0>, ir<false>
553 ; CHECK-NEXT: Successor(s): pred.load
555 ; CHECK-NEXT: <xVFxUF> pred.load: {
556 ; CHECK-NEXT: pred.load.entry:
557 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK2]]>
558 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
560 ; CHECK-NEXT: pred.load.if:
561 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
562 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
563 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b>
564 ; CHECK-NEXT: Successor(s): pred.load.continue
566 ; CHECK-NEXT: pred.load.continue:
567 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv.b>
568 ; CHECK-NEXT: No successors
570 ; CHECK-NEXT: Successor(s): then.0.0
572 ; CHECK-NEXT: then.0.0:
573 ; CHECK-NEXT: EMIT vp<[[NOT:%.+]]> = not ir<%c.0>
574 ; CHECK-NEXT: EMIT vp<[[MASK3:%.+]]> = select vp<[[MASK1]]>, vp<[[NOT]]>, ir<false>
575 ; CHECK-NEXT: EMIT vp<[[MASK4:%.+]]> = or vp<[[MASK2]]>, vp<[[MASK3]]>
576 ; CHECK-NEXT: BLEND ir<%p> = ir<0>/vp<[[MASK3]]> vp<[[PRED]]>/vp<[[MASK2]]>
577 ; CHECK-NEXT: EMIT vp<[[MASK5:%.+]]> = select vp<[[MASK4]]>, ir<%c.0>, ir<false>
578 ; CHECK-NEXT: Successor(s): pred.store
580 ; CHECK-NEXT: <xVFxUF> pred.store: {
581 ; CHECK-NEXT: pred.store.entry:
582 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK5]]>
583 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
585 ; CHECK-NEXT: pred.store.if:
586 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, ir<%mul>
587 ; CHECK-NEXT: REPLICATE store ir<0>, ir<%gep.a>
588 ; CHECK-NEXT: REPLICATE ir<%gep.c> = getelementptr inbounds ir<@c>, ir<0>, ir<%mul>
589 ; CHECK-NEXT: REPLICATE store ir<%p>, ir<%gep.c>
590 ; CHECK-NEXT: Successor(s): pred.store.continue
592 ; CHECK-NEXT: pred.store.continue:
593 ; CHECK-NEXT: No successors
595 ; CHECK-NEXT: Successor(s): then.1.2
597 ; CHECK-NEXT: then.1.2:
598 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
599 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
600 ; CHECK-NEXT: No successors
607 %iv = phi i32 [ 0, %entry ], [ %iv.next, %next.1 ]
608 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
609 %mul = mul i32 %iv, 10
610 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %mul
611 %gep.c = getelementptr inbounds [2048 x i32], ptr @c, i32 0, i32 %mul
612 %c.0 = icmp ult i32 %iv, %j
613 br i1 %c.0, label %then.0, label %next.0
616 %lv.b = load i32, ptr %gep.b, align 4
620 %p = phi i32 [ 0, %loop ], [ %lv.b, %then.0 ]
621 br i1 %c.0, label %then.1, label %next.1
624 store i32 0, ptr %gep.a, align 4
625 store i32 %p, ptr %gep.c, align 4
629 %iv.next = add i32 %iv, 1
630 %large = icmp sge i32 %iv, 8
631 %exitcond = icmp eq i32 %iv, %k
632 %realexit = or i1 %large, %exitcond
633 br i1 %realexit, label %exit, label %loop
639 define void @merge_3_replicate_region(i32 %k, i32 %j) {
640 ; CHECK-LABEL: LV: Checking a loop in 'merge_3_replicate_region'
641 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
642 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
643 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
644 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
645 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
648 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
649 ; CHECK-NEXT: No successors
651 ; CHECK-NEXT: vector.ph:
652 ; CHECK-NEXT: Successor(s): vector loop
654 ; CHECK-NEXT: <x1> vector loop: {
655 ; CHECK-NEXT: vector.body:
656 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
657 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
658 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
659 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
660 ; CHECK-NEXT: Successor(s): pred.store
662 ; CHECK-NEXT: <xVFxUF> pred.store: {
663 ; CHECK-NEXT: pred.store.entry:
664 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
665 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
667 ; CHECK-NEXT: pred.store.if:
668 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, vp<[[STEPS]]>
669 ; CHECK-NEXT: REPLICATE ir<%lv.a> = load ir<%gep.a>
670 ; CHECK-NEXT: REPLICATE ir<%gep.b> = getelementptr inbounds ir<@b>, ir<0>, vp<[[STEPS]]>
671 ; CHECK-NEXT: REPLICATE ir<%lv.b> = load ir<%gep.b>
672 ; CHECK-NEXT: REPLICATE ir<%gep.c> = getelementptr inbounds ir<@c>, ir<0>, vp<[[STEPS]]>
673 ; CHECK-NEXT: REPLICATE store ir<%lv.a>, ir<%gep.c>
674 ; CHECK-NEXT: REPLICATE store ir<%lv.b>, ir<%gep.a>
675 ; CHECK-NEXT: Successor(s): pred.store.continue
677 ; CHECK-NEXT: pred.store.continue:
678 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED1:%.+]]> = ir<%lv.a>
679 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%lv.b>
680 ; CHECK-NEXT: No successors
682 ; CHECK-NEXT: Successor(s): loop.3
684 ; CHECK-NEXT: loop.3:
685 ; CHECK-NEXT: WIDEN ir<%c.0> = icmp ult ir<%iv>, ir<%j>
686 ; CHECK-NEXT: EMIT vp<[[MASK2:%.+]]> = select vp<[[MASK]]>, ir<%c.0>, ir<false>
687 ; CHECK-NEXT: WIDEN ir<%mul> = mul vp<[[PRED1]]>, vp<[[PRED2]]>
688 ; CHECK-NEXT: Successor(s): pred.store
690 ; CHECK-NEXT: <xVFxUF> pred.store: {
691 ; CHECK-NEXT: pred.store.entry:
692 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK2]]>
693 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
695 ; CHECK-NEXT: pred.store.if:
696 ; CHECK-NEXT: REPLICATE ir<%gep.c.1> = getelementptr inbounds ir<@c>, ir<0>, vp<[[STEPS]]>
697 ; CHECK-NEXT: REPLICATE store ir<%mul>, ir<%gep.c.1>
698 ; CHECK-NEXT: Successor(s): pred.store.continue
700 ; CHECK-NEXT: pred.store.continue:
701 ; CHECK-NEXT: No successors
703 ; CHECK-NEXT: Successor(s): then.0.4
705 ; CHECK-NEXT: then.0.4:
706 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
707 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
708 ; CHECK-NEXT: No successors
715 %iv = phi i32 [ 0, %entry ], [ %iv.next, %latch ]
716 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %iv
717 %lv.a = load i32, ptr %gep.a, align 4
718 %gep.b = getelementptr inbounds [2048 x i32], ptr @b, i32 0, i32 %iv
719 %lv.b = load i32, ptr %gep.b, align 4
720 %gep.c = getelementptr inbounds [2048 x i32], ptr @c, i32 0, i32 %iv
721 store i32 %lv.a, ptr %gep.c, align 4
722 store i32 %lv.b, ptr %gep.a, align 4
723 %c.0 = icmp ult i32 %iv, %j
724 br i1 %c.0, label %then.0, label %latch
727 %mul = mul i32 %lv.a, %lv.b
728 %gep.c.1 = getelementptr inbounds [2048 x i32], ptr @c, i32 0, i32 %iv
729 store i32 %mul, ptr %gep.c.1, align 4
733 %iv.next = add i32 %iv, 1
734 %large = icmp sge i32 %iv, 8
735 %exitcond = icmp eq i32 %iv, %k
736 %realexit = or i1 %large, %exitcond
737 br i1 %realexit, label %exit, label %loop
744 define void @update_2_uses_in_same_recipe_in_merged_block(i32 %k) {
745 ; CHECK-LABEL: LV: Checking a loop in 'update_2_uses_in_same_recipe_in_merged_block'
746 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
747 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
748 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
749 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
750 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
753 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
754 ; CHECK-NEXT: No successors
756 ; CHECK-NEXT: vector.ph:
757 ; CHECK-NEXT: Successor(s): vector loop
759 ; CHECK-NEXT: <x1> vector loop: {
760 ; CHECK-NEXT: vector.body:
761 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
762 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
763 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
764 ; CHECK-NEXT: Successor(s): pred.store
766 ; CHECK-NEXT: <xVFxUF> pred.store: {
767 ; CHECK-NEXT: pred.store.entry:
768 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
769 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
771 ; CHECK-NEXT: pred.store.if:
772 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
773 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, vp<[[STEPS]]>
774 ; CHECK-NEXT: REPLICATE ir<%lv.a> = load ir<%gep.a>
775 ; CHECK-NEXT: REPLICATE ir<%div> = sdiv ir<%lv.a>, ir<%lv.a>
776 ; CHECK-NEXT: REPLICATE store ir<%div>, ir<%gep.a>
777 ; CHECK-NEXT: Successor(s): pred.store.continue
779 ; CHECK-NEXT: pred.store.continue:
780 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED1:%.+]]> = ir<%lv.a>
781 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%div>
782 ; CHECK-NEXT: No successors
784 ; CHECK-NEXT: Successor(s): loop.2
786 ; CHECK-NEXT: loop.2:
787 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
788 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
789 ; CHECK-NEXT: No successors
796 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
797 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %iv
798 %lv.a = load i32, ptr %gep.a, align 4
799 %div = sdiv i32 %lv.a, %lv.a
800 store i32 %div, ptr %gep.a, align 4
801 %iv.next = add i32 %iv, 1
802 %large = icmp sge i32 %iv, 8
803 %exitcond = icmp eq i32 %iv, %k
804 %realexit = or i1 %large, %exitcond
805 br i1 %realexit, label %exit, label %loop
811 define void @recipe_in_merge_candidate_used_by_first_order_recurrence(i32 %k) {
812 ; CHECK-LABEL: LV: Checking a loop in 'recipe_in_merge_candidate_used_by_first_order_recurrence'
813 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
814 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
815 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
816 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
817 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
820 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 + (8 umin %k))<nuw><nsw>
821 ; CHECK-NEXT: No successors
823 ; CHECK-NEXT: vector.ph:
824 ; CHECK-NEXT: Successor(s): vector loop
826 ; CHECK-NEXT: <x1> vector loop: {
827 ; CHECK-NEXT: vector.body:
828 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
829 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
830 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%for> = phi ir<0>, vp<[[PRED:%.+]]>
831 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
832 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
833 ; CHECK-NEXT: REPLICATE ir<%gep.a> = getelementptr inbounds ir<@a>, ir<0>, vp<[[STEPS]]>
834 ; CHECK-NEXT: Successor(s): pred.load
836 ; CHECK-NEXT: <xVFxUF> pred.load: {
837 ; CHECK-NEXT: pred.load.entry:
838 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
839 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
841 ; CHECK-NEXT: pred.load.if:
842 ; CHECK-NEXT: REPLICATE ir<%lv.a> = load ir<%gep.a>
843 ; CHECK-NEXT: Successor(s): pred.load.continue
845 ; CHECK-NEXT: pred.load.continue:
846 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED]]> = ir<%lv.a>
847 ; CHECK-NEXT: No successors
849 ; CHECK-NEXT: Successor(s): loop.0
851 ; CHECK-NEXT: loop.0:
852 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%for>, vp<[[PRED]]>
853 ; CHECK-NEXT: Successor(s): pred.store
855 ; CHECK-NEXT: <xVFxUF> pred.store: {
856 ; CHECK-NEXT: pred.store.entry:
857 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
858 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
860 ; CHECK-NEXT: pred.store.if:
861 ; CHECK-NEXT: REPLICATE ir<%div> = sdiv vp<[[SPLICE]]>, vp<[[PRED]]>
862 ; CHECK-NEXT: REPLICATE store ir<%div>, ir<%gep.a>
863 ; CHECK-NEXT: Successor(s): pred.store.continue
865 ; CHECK-NEXT: pred.store.continue:
866 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%div>
867 ; CHECK-NEXT: No successors
869 ; CHECK-NEXT: Successor(s): loop.2
871 ; CHECK-NEXT: loop.2:
872 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
873 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
874 ; CHECK-NEXT: No successors
881 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
882 %for = phi i32 [ 0, %entry ], [ %lv.a, %loop ]
883 %gep.a = getelementptr inbounds [2048 x i32], ptr @a, i32 0, i32 %iv
884 %lv.a = load i32, ptr %gep.a, align 4
885 %div = sdiv i32 %for, %lv.a
886 store i32 %div, ptr %gep.a, align 4
887 %iv.next = add i32 %iv, 1
888 %large = icmp sge i32 %iv, 8
889 %exitcond = icmp eq i32 %iv, %k
890 %realexit = or i1 %large, %exitcond
891 br i1 %realexit, label %exit, label %loop
897 define void @update_multiple_users(ptr noalias %src, ptr noalias %dst, i1 %c) {
898 ; CHECK-LABEL: LV: Checking a loop in 'update_multiple_users'
899 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
900 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
901 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
902 ; CHECK-NEXT: Live-in ir<999> = original trip-count
904 ; CHECK-NEXT: vector.ph:
905 ; CHECK-NEXT: Successor(s): vector loop
907 ; CHECK-NEXT: <x1> vector loop: {
908 ; CHECK-NEXT: vector.body:
909 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
910 ; CHECK-NEXT: Successor(s): pred.store
912 ; CHECK-NEXT: <xVFxUF> pred.store: {
913 ; CHECK-NEXT: pred.store.entry:
914 ; CHECK-NEXT: BRANCH-ON-MASK ir<%c>
915 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
917 ; CHECK-NEXT: pred.store.if:
918 ; CHECK-NEXT: REPLICATE ir<%l1> = load ir<%src>
919 ; CHECK-NEXT: REPLICATE ir<%l2> = trunc ir<%l1>
920 ; CHECK-NEXT: REPLICATE ir<%cmp> = icmp eq ir<%l1>, ir<0>
921 ; CHECK-NEXT: REPLICATE ir<%sel> = select ir<%cmp>, ir<5>, ir<%l2>
922 ; CHECK-NEXT: REPLICATE store ir<%sel>, ir<%dst>
923 ; CHECK-NEXT: Successor(s): pred.store.continue
925 ; CHECK-NEXT: pred.store.continue:
926 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%l1>
927 ; CHECK-NEXT: No successors
929 ; CHECK-NEXT: Successor(s): loop.then.1
931 ; CHECK-NEXT: loop.then.1:
932 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
933 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
934 ; CHECK-NEXT: No successors
938 br label %loop.header
941 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
942 br i1 %c, label %loop.then, label %loop.latch
945 %l1 = load i16, ptr %src, align 2
946 %l2 = trunc i16 %l1 to i8
947 %cmp = icmp eq i16 %l1, 0
948 %sel = select i1 %cmp, i8 5, i8 %l2
949 store i8 %sel, ptr %dst, align 1
950 %sext.l1 = sext i16 %l1 to i32
954 %iv.next = add nsw i64 %iv, 1
955 %ec = icmp eq i64 %iv.next, 999
956 br i1 %ec, label %exit, label %loop.header
962 define void @sinking_requires_duplication(ptr %addr) {
963 ; CHECK-LABEL: LV: Checking a loop in 'sinking_requires_duplication'
964 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
965 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
966 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
967 ; CHECK-NEXT: Live-in ir<201> = original trip-count
969 ; CHECK-NEXT: vector.ph:
970 ; CHECK-NEXT: Successor(s): vector loop
972 ; CHECK-NEXT: <x1> vector loop: {
973 ; CHECK-NEXT: vector.body:
974 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
975 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
976 ; CHECK-NEXT: CLONE ir<%gep> = getelementptr ir<%addr>, vp<[[STEPS]]>
977 ; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%gep>
978 ; CHECK-NEXT: WIDEN ir<%0> = load vp<[[VEC_PTR]]>
979 ; CHECK-NEXT: WIDEN ir<%pred> = fcmp oeq ir<%0>, ir<0.000000e+00>
980 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = not ir<%pred>
981 ; CHECK-NEXT: Successor(s): pred.store
983 ; CHECK-NEXT: <xVFxUF> pred.store: {
984 ; CHECK-NEXT: pred.store.entry:
985 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
986 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
988 ; CHECK-NEXT: pred.store.if:
989 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%addr>, vp<[[STEPS]]>
990 ; CHECK-NEXT: REPLICATE store ir<1.000000e+01>, ir<%gep>
991 ; CHECK-NEXT: Successor(s): pred.store.continue
993 ; CHECK-NEXT: pred.store.continue:
994 ; CHECK-NEXT: No successors
996 ; CHECK-NEXT: Successor(s): then.0
998 ; CHECK-NEXT: then.0:
999 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
1000 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
1001 ; CHECK-NEXT: No successors
1005 br label %loop.header
1008 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
1009 %gep = getelementptr float, ptr %addr, i64 %iv
1010 %exitcond.not = icmp eq i64 %iv, 200
1011 br i1 %exitcond.not, label %exit, label %loop.body
1014 %0 = load float, ptr %gep, align 4
1015 %pred = fcmp oeq float %0, 0.0
1016 br i1 %pred, label %loop.latch, label %then
1019 store float 10.0, ptr %gep, align 4
1020 br label %loop.latch
1023 %iv.next = add nuw nsw i64 %iv, 1
1024 br label %loop.header
1030 ; Test case with a dead GEP between the load and store regions. Dead recipes
1031 ; need to be removed before merging.
1032 define void @merge_with_dead_gep_between_regions(i32 %n, ptr noalias %src, ptr noalias %dst) optsize {
1033 ; CHECK-LABEL: LV: Checking a loop in 'merge_with_dead_gep_between_regions'
1034 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
1035 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
1036 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
1037 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
1038 ; CHECK-NEXT: Live-in ir<%n> = original trip-count
1040 ; CHECK-NEXT: vector.ph:
1041 ; CHECK-NEXT: Successor(s): vector loop
1043 ; CHECK-NEXT: <x1> vector loop: {
1044 ; CHECK-NEXT: vector.body:
1045 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
1046 ; CHECK-NEXT: vp<[[DERIVED_IV:%.+]]> = DERIVED-IV ir<%n> + vp<[[CAN_IV]]> * ir<-1>
1047 ; CHECK-NEXT: EMIT vp<[[WIDE_IV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
1048 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule vp<[[WIDE_IV]]>, vp<[[BTC]]>
1049 ; CHECK-NEXT: Successor(s): pred.store
1051 ; CHECK-NEXT: <xVFxUF> pred.store: {
1052 ; CHECK-NEXT: pred.store.entry:
1053 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
1054 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
1056 ; CHECK-NEXT: pred.store.if:
1057 ; CHECK-NEXT: vp<[[SCALAR_STEPS:%.+]]> = SCALAR-STEPS vp<[[DERIVED_IV]]>, ir<-1>
1058 ; CHECK-NEXT: REPLICATE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[SCALAR_STEPS]]>
1059 ; CHECK-NEXT: REPLICATE ir<%l> = load ir<%gep.src>
1060 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[SCALAR_STEPS]]>
1061 ; CHECK-NEXT: REPLICATE store ir<%l>, ir<%gep.dst>
1062 ; CHECK-NEXT: Successor(s): pred.store.continue
1064 ; CHECK-NEXT: pred.store.continue:
1065 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[P_LOAD:%.+]]> = ir<%l>
1066 ; CHECK-NEXT: No successors
1068 ; CHECK-NEXT: Successor(s): loop.1
1070 ; CHECK-NEXT: loop.1:
1071 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
1072 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
1073 ; CHECK-NEXT: No successors
1075 ; CHECK-NEXT: Successor(s): middle.block
1077 ; CHECK-NEXT: middle.block:
1078 ; CHECK-NEXT: No successors
1085 %iv = phi i32[ %n, %entry ], [ %iv.next, %loop ]
1086 %iv.next = add nsw i32 %iv, -1
1087 %gep.src = getelementptr inbounds i32, ptr %src, i32 %iv
1088 %l = load i32, ptr %gep.src, align 16
1089 %dead_gep = getelementptr inbounds i32, ptr %dst, i64 1
1090 %gep.dst = getelementptr inbounds i32, ptr %dst, i32 %iv
1091 store i32 %l, ptr %gep.dst, align 16
1092 %ec = icmp eq i32 %iv.next, 0
1093 br i1 %ec, label %exit, label %loop
1099 define void @ptr_induction_remove_dead_recipe(ptr %start, ptr %end) {
1100 ; CHECK-LABEL: LV: Checking a loop in 'ptr_induction_remove_dead_recipe'
1101 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
1102 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
1103 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
1104 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
1107 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV ((-1 * (ptrtoint ptr %end to i64)) + (ptrtoint ptr %start to i64))
1108 ; CHECK-NEXT: No successors
1110 ; CHECK-NEXT: vector.ph:
1111 ; CHECK-NEXT: Successor(s): vector loop
1113 ; CHECK-NEXT: <x1> vector loop: {
1114 ; CHECK-NEXT: vector.body:
1115 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
1116 ; CHECK-NEXT: EMIT ir<%ptr.iv> = WIDEN-POINTER-INDUCTION ir<%start>, -1
1117 ; CHECK-NEXT: CLONE ir<%ptr.iv.next> = getelementptr inbounds ir<%ptr.iv>, ir<-1>
1118 ; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer (reverse) ir<%ptr.iv.next>
1119 ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]>
1120 ; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<0>
1121 ; CHECK-NEXT: EMIT vp<[[NEG:%.+]]> = not ir<%c.1>
1122 ; CHECK-NEXT: Successor(s): pred.store
1124 ; CHECK-NEXT: <xVFxUF> pred.store: {
1125 ; CHECK-NEXT: pred.store.entry:
1126 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[NEG]]>
1127 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
1129 ; CHECK-NEXT: pred.store.if:
1130 ; CHECK-NEXT: REPLICATE ir<%ptr.iv.next> = getelementptr inbounds ir<%ptr.iv>, ir<-1>
1131 ; CHECK-NEXT: REPLICATE store ir<95>, ir<%ptr.iv.next>
1132 ; CHECK-NEXT: Successor(s): pred.store.continue
1134 ; CHECK-NEXT: pred.store.continue:
1135 ; CHECK-NEXT: No successors
1137 ; CHECK-NEXT: Successor(s): if.then.0
1139 ; CHECK-NEXT: if.then.0:
1140 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
1141 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
1142 ; CHECK-NEXT: No successors
1144 ; CHECK-NEXT: Successor(s): middle.block
1146 ; CHECK-NEXT: middle.block:
1147 ; CHECK-NEXT: No successors
1151 br label %loop.header
1154 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
1155 %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 -1
1156 %l = load i8, ptr %ptr.iv.next, align 1
1157 %c.1 = icmp eq i8 %l, 0
1158 br i1 %c.1, label %loop.latch, label %if.then
1161 store i8 95, ptr %ptr.iv.next, align 1
1162 br label %loop.latch
1165 %c.2 = icmp eq ptr %ptr.iv.next, %end
1166 br i1 %c.2, label %exit, label %loop.header