2 ; RUN: opt < %s -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -force-widen-divrem-via-safe-divisor=0 -disable-output -debug-only=loop-vectorize 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
6 ; Test cases for PR50009, which require sinking a replicate-region due to a
7 ; first-order recurrence.
9 define void @sink_replicate_region_1(i32 %x, ptr %ptr, ptr noalias %dst) optsize {
10 ; CHECK-LABEL: sink_replicate_region_1
11 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
12 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
13 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
14 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
15 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
17 ; CHECK-NEXT: vector.ph:
18 ; CHECK-NEXT: Successor(s): vector loop
20 ; CHECK-NEXT: <x1> vector loop: {
21 ; CHECK-NEXT: vector.body:
22 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
23 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%0> = phi ir<0>, ir<%conv>
24 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
25 ; CHECK-NEXT: vp<[[STEPS:%.]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
26 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
27 ; CHECK-NEXT: Successor(s): pred.load
29 ; CHECK-NEXT: <xVFxUF> pred.load: {
30 ; CHECK-NEXT: pred.load.entry:
31 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
32 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
34 ; CHECK-NEXT: pred.load.if:
35 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
36 ; CHECK-NEXT: REPLICATE ir<%lv> = load ir<%gep> (S->V)
37 ; CHECK-NEXT: Successor(s): pred.load.continue
39 ; CHECK-NEXT: pred.load.continue:
40 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED1:%.+]]> = ir<%lv>
41 ; CHECK-NEXT: No successors
43 ; CHECK-NEXT: Successor(s): loop.0
46 ; CHECK-NEXT: WIDEN-CAST ir<%conv> = sext vp<[[PRED1]]> to i32
47 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%0>, ir<%conv>
48 ; CHECK-NEXT: Successor(s): pred.store
50 ; CHECK-NEXT: <xVFxUF> pred.store: {
51 ; CHECK-NEXT: pred.store.entry:
52 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
53 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
55 ; CHECK-NEXT: pred.store.if:
56 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
57 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[STEPS]]>
58 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%conv>, ir<%rem>
59 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep.dst>
60 ; CHECK-NEXT: Successor(s): pred.store.continue
62 ; CHECK-NEXT: pred.store.continue:
63 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%rem>
64 ; CHECK-NEXT: No successors
66 ; CHECK-NEXT: Successor(s): loop.2
69 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
70 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
71 ; CHECK-NEXT: No successors
73 ; CHECK-NEXT: Successor(s): middle.block
75 ; CHECK-NEXT: middle.block:
76 ; CHECK-NEXT: No successors
83 %0 = phi i32 [ 0, %entry ], [ %conv, %loop ]
84 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
85 %rem = srem i32 %0, %x
86 %gep = getelementptr i8, ptr %ptr, i32 %iv
87 %lv = load i8, ptr %gep
88 %conv = sext i8 %lv to i32
89 %add = add i32 %conv, %rem
90 %gep.dst = getelementptr i32, ptr %dst, i32 %iv
91 store i32 %add, ptr %gep.dst
92 %iv.next = add nsw i32 %iv, 1
93 %ec = icmp eq i32 %iv.next, 20001
94 br i1 %ec, label %exit, label %loop
100 define void @sink_replicate_region_2(i32 %x, i8 %y, ptr %ptr) optsize {
101 ; CHECK-LABEL: sink_replicate_region_2
102 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
103 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
104 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
105 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
106 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
108 ; CHECK-NEXT: vector.ph:
109 ; CHECK-NEXT: Successor(s): vector loop
111 ; CHECK-NEXT: <x1> vector loop: {
112 ; CHECK-NEXT: vector.body:
113 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
114 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
115 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
116 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
117 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
118 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
119 ; CHECK-NEXT: Successor(s): pred.store
121 ; CHECK-NEXT: <xVFxUF> pred.store: {
122 ; CHECK-NEXT: pred.store.entry:
123 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
124 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
126 ; CHECK-NEXT: pred.store.if:
127 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
128 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
129 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
130 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%rem>, ir<%recur.next>
131 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep>
132 ; CHECK-NEXT: Successor(s): pred.store.continue
134 ; CHECK-NEXT: pred.store.continue:
135 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%rem>
136 ; CHECK-NEXT: No successors
138 ; CHECK-NEXT: Successor(s): loop.1
140 ; CHECK-NEXT: loop.1:
141 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
142 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
143 ; CHECK-NEXT: No successors
145 ; CHECK-NEXT: Successor(s): middle.block
147 ; CHECK-NEXT: middle.block:
148 ; CHECK-NEXT: No successors
155 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
156 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
157 %rem = srem i32 %recur, %x
158 %recur.next = sext i8 %y to i32
159 %add = add i32 %rem, %recur.next
160 %gep = getelementptr i32, ptr %ptr, i32 %iv
161 store i32 %add, ptr %gep
162 %iv.next = add nsw i32 %iv, 1
163 %ec = icmp eq i32 %iv.next, 20001
164 br i1 %ec, label %exit, label %loop
170 define i32 @sink_replicate_region_3_reduction(i32 %x, i8 %y, ptr %ptr) optsize {
171 ; CHECK-LABEL: sink_replicate_region_3_reduction
172 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
173 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
174 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
175 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
176 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
178 ; CHECK-NEXT: vector.ph:
179 ; CHECK-NEXT: Successor(s): vector loop
181 ; CHECK-NEXT: <x1> vector loop: {
182 ; CHECK-NEXT: vector.body:
183 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
184 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
185 ; CHECK-NEXT: WIDEN-REDUCTION-PHI ir<%and.red> = phi ir<1234>, ir<%and.red.next>
186 ; CHECK-NEXT: EMIT vp<[[WIDEN_CAN:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
187 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule vp<[[WIDEN_CAN]]>, vp<[[BTC]]>
188 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
189 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
190 ; CHECK-NEXT: Successor(s): pred.srem
192 ; CHECK-NEXT: <xVFxUF> pred.srem: {
193 ; CHECK-NEXT: pred.srem.entry:
194 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
195 ; CHECK-NEXT: Successor(s): pred.srem.if, pred.srem.continue
197 ; CHECK-NEXT: pred.srem.if:
198 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x> (S->V)
199 ; CHECK-NEXT: Successor(s): pred.srem.continue
201 ; CHECK-NEXT: pred.srem.continue:
202 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%rem>
203 ; CHECK-NEXT: No successors
205 ; CHECK-NEXT: Successor(s): loop.0
207 ; CHECK-NEXT: loop.0:
208 ; CHECK-NEXT: WIDEN ir<%add> = add vp<[[PRED]]>, ir<%recur.next>
209 ; CHECK-NEXT: WIDEN ir<%and.red.next> = and ir<%and.red>, ir<%add>
210 ; CHECK-NEXT: EMIT vp<[[SEL:%.+]]> = select vp<[[MASK]]>, ir<%and.red.next>, ir<%and.red>
211 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
212 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
213 ; CHECK-NEXT: No successors
215 ; CHECK-NEXT: Successor(s): middle.block
217 ; CHECK-NEXT: middle.block:
218 ; CHECK-NEXT: EMIT vp<[[RED_RES:%.+]]> = compute-reduction-result ir<%and.red>, vp<[[SEL]]>
219 ; CHECK-NEXT: No successors
221 ; CHECK-NEXT: Live-out i32 %res = vp<[[RED_RES]]>
228 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
229 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
230 %and.red = phi i32 [ 1234, %entry ], [ %and.red.next, %loop ]
231 %rem = srem i32 %recur, %x
232 %recur.next = sext i8 %y to i32
233 %add = add i32 %rem, %recur.next
234 %and.red.next = and i32 %and.red, %add
235 %iv.next = add nsw i32 %iv, 1
236 %ec = icmp eq i32 %iv.next, 20001
237 br i1 %ec, label %exit, label %loop
240 %res = phi i32 [ %and.red.next, %loop ]
244 ; To sink the replicate region containing %rem, we need to split the block
245 ; containing %conv at the end, because %conv is the last recipe in the block.
246 define void @sink_replicate_region_4_requires_split_at_end_of_block(i32 %x, ptr %ptr, ptr noalias %dst) optsize {
247 ; CHECK-LABEL: sink_replicate_region_4_requires_split_at_end_of_block
248 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
249 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
250 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
251 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
252 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
254 ; CHECK-NEXT: vector.ph:
255 ; CHECK-NEXT: Successor(s): vector loop
257 ; CHECK-NEXT: <x1> vector loop: {
258 ; CHECK-NEXT: vector.body:
259 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
260 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%0> = phi ir<0>, ir<%conv>
261 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
262 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
263 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
264 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
265 ; CHECK-NEXT: Successor(s): pred.load
267 ; CHECK-NEXT: <xVFxUF> pred.load: {
268 ; CHECK-NEXT: pred.load.entry:
269 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
270 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
272 ; CHECK-NEXT: pred.load.if:
273 ; CHECK-NEXT: REPLICATE ir<%lv> = load ir<%gep> (S->V)
274 ; CHECK-NEXT: Successor(s): pred.load.continue
276 ; CHECK-NEXT: pred.load.continue:
277 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv>
278 ; CHECK-NEXT: No successors
280 ; CHECK-NEXT: Successor(s): loop.0
282 ; CHECK-NEXT: loop.0:
283 ; CHECK-NEXT: WIDEN-CAST ir<%conv> = sext vp<[[PRED]]> to i32
284 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%0>, ir<%conv>
285 ; CHECK-NEXT: Successor(s): pred.store
287 ; CHECK: <xVFxUF> pred.store: {
288 ; CHECK-NEXT: pred.store.entry:
289 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
290 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
292 ; CHECK: pred.store.if:
293 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
294 ; CHECK-NEXT: REPLICATE ir<%lv.2> = load ir<%gep>
295 ; CHECK-NEXT: REPLICATE ir<%conv.lv.2> = sext ir<%lv.2>
296 ; CHECK-NEXT: REPLICATE ir<%add.1> = add ir<%conv>, ir<%rem>
297 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[STEPS]]>
298 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%add.1>, ir<%conv.lv.2>
299 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep.dst>
300 ; CHECK-NEXT: Successor(s): pred.store.continue
302 ; CHECK: pred.store.continue:
303 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED1:%.+]]> = ir<%rem>
304 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%lv.2>
305 ; CHECK-NEXT: No successors
307 ; CHECK-NEXT: Successor(s): loop.3
310 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
311 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
312 ; CHECK-NEXT: No successors
314 ; CHECK-NEXT: Successor(s): middle.block
316 ; CHECK-NEXT: middle.block:
317 ; CHECK-NEXT: No successors
324 %0 = phi i32 [ 0, %entry ], [ %conv, %loop ]
325 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
326 %gep = getelementptr i8, ptr %ptr, i32 %iv
327 %rem = srem i32 %0, %x
328 %lv = load i8, ptr %gep
329 %conv = sext i8 %lv to i32
330 %lv.2 = load i8, ptr %gep
331 %add.1 = add i32 %conv, %rem
332 %conv.lv.2 = sext i8 %lv.2 to i32
333 %add = add i32 %add.1, %conv.lv.2
334 %gep.dst = getelementptr i32, ptr %dst, i32 %iv
335 store i32 %add, ptr %gep.dst
336 %iv.next = add nsw i32 %iv, 1
337 %ec = icmp eq i32 %iv.next, 20001
338 br i1 %ec, label %exit, label %loop
344 ; Test case that requires sinking a recipe in a replicate region after another replicate region.
345 define void @sink_replicate_region_after_replicate_region(ptr %ptr, ptr noalias %dst.2, i32 %x, i8 %y) optsize {
346 ; CHECK-LABEL: sink_replicate_region_after_replicate_region
347 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
348 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
349 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
350 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
351 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
354 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 smax (1 + (sext i8 %y to i32))<nsw>)
355 ; CHECK-NEXT: No successors
357 ; CHECK-NEXT: vector.ph:
358 ; CHECK-NEXT: Successor(s): vector loop
360 ; CHECK-NEXT: <x1> vector loop: {
361 ; CHECK-NEXT: vector.body:
362 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
363 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
364 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
365 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
366 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
367 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
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<[[MASK]]>
373 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
375 ; CHECK-NEXT: pred.store.if:
376 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
377 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
378 ; CHECK-NEXT: REPLICATE ir<%rem.div> = sdiv ir<20>, ir<%rem>
379 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
380 ; CHECK-NEXT: REPLICATE store ir<%rem.div>, ir<%gep>
381 ; CHECK-NEXT: REPLICATE ir<%gep.2> = getelementptr ir<%dst.2>, vp<[[STEPS]]>
382 ; CHECK-NEXT: REPLICATE store ir<%rem.div>, ir<%gep.2>
383 ; CHECK-NEXT: Successor(s): pred.store.continue
385 ; CHECK-NEXT: pred.store.continue:
386 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%rem>
387 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED2:%.+]]> = ir<%rem.div>
388 ; CHECK-NEXT: No successors
390 ; CHECK-NEXT: Successor(s): loop.3
392 ; CHECK-NEXT: loop.3:
393 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
394 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
395 ; CHECK-NEXT: No successors
397 ; CHECK-NEXT: Successor(s): middle.block
399 ; CHECK-NEXT: middle.block:
400 ; CHECK-NEXT: No successors
406 loop: ; preds = %loop, %entry
407 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
408 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
409 %rem = srem i32 %recur, %x
410 %rem.div = sdiv i32 20, %rem
411 %recur.next = sext i8 %y to i32
412 %gep = getelementptr i32, ptr %ptr, i32 %iv
413 store i32 %rem.div, ptr %gep
414 %gep.2 = getelementptr i32, ptr %dst.2, i32 %iv
415 store i32 %rem.div, ptr %gep.2
416 %iv.next = add nsw i32 %iv, 1
417 %C = icmp sgt i32 %iv.next, %recur.next
418 br i1 %C, label %exit, label %loop
420 exit: ; preds = %loop
424 define void @need_new_block_after_sinking_pr56146(i32 %x, ptr %src, ptr noalias %dst) {
425 ; CHECK-LABEL: need_new_block_after_sinking_pr56146
426 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
427 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
428 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
429 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
430 ; CHECK-NEXT: Live-in ir<3> = original trip-count
432 ; CHECK-NEXT: vector.ph:
433 ; CHECK-NEXT: Successor(s): vector loop
435 ; CHECK-NEXT: <x1> vector loop: {
436 ; CHECK-NEXT: vector.body:
437 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
438 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%.pn> = phi ir<0>, ir<[[L:%.+]]>
439 ; CHECK-NEXT: vp<[[DERIVED_IV:%.+]]> = DERIVED-IV ir<2> + vp<[[CAN_IV]]> * ir<1>
440 ; CHECK-NEXT: EMIT vp<[[WIDE_IV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
441 ; CHECK-NEXT: EMIT vp<[[CMP:%.+]]> = icmp ule vp<[[WIDE_IV]]>, vp<[[BTC]]>
442 ; CHECK-NEXT: CLONE ir<[[L]]> = load ir<%src>
443 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%.pn>, ir<[[L]]>
444 ; CHECK-NEXT: Successor(s): pred.store
446 ; CHECK-NEXT: <xVFxUF> pred.store: {
447 ; CHECK-NEXT: pred.store.entry:
448 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[CMP]]>
449 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
451 ; CHECK-NEXT: pred.store.if:
452 ; CHECK-NEXT: REPLICATE ir<%val> = sdiv vp<[[SPLICE]]>, ir<%x>
453 ; CHECK-NEXT: vp<[[SCALAR_STEPS:%.+]]> = SCALAR-STEPS vp<[[DERIVED_IV]]>, ir<1>
454 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[SCALAR_STEPS]]>
455 ; CHECK-NEXT: REPLICATE store ir<%val>, ir<%gep.dst>
456 ; CHECK-NEXT: Successor(s): pred.store.continue
458 ; CHECK-NEXT: pred.store.continue:
459 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[P_VAL:%.+]]> = ir<%val>
460 ; CHECK-NEXT: No successors
462 ; CHECK-NEXT: Successor(s): loop.1
464 ; CHECK-NEXT: loop.1:
465 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
466 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
467 ; CHECK-NEXT: No successors
469 ; CHECK-NEXT: Successor(s): middle.block
471 ; CHECK-NEXT: middle.block:
472 ; CHECK-NEXT: No successors
479 %iv = phi i64 [ 2, %entry ], [ %iv.next, %loop ]
480 %.pn = phi i32 [ 0, %entry ], [ %l, %loop ]
481 %val = sdiv i32 %.pn, %x
482 %l = load i32, ptr %src, align 4
483 %gep.dst = getelementptr i32, ptr %dst, i64 %iv
484 store i32 %val, ptr %gep.dst
485 %iv.next = add nuw nsw i64 %iv, 1
486 %ec = icmp ugt i64 %iv, 3
487 br i1 %ec, label %exit, label %loop