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: No successors
65 ; CHECK-NEXT: Successor(s): loop.2
68 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
69 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
70 ; CHECK-NEXT: No successors
72 ; CHECK-NEXT: Successor(s): middle.block
74 ; CHECK-NEXT: middle.block:
75 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%conv>, ir<1>
76 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
77 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
79 ; CHECK-NEXT: ir-bb<exit>
80 ; CHECK-NEXT: No successors
82 ; CHECK-NEXT: scalar.ph
83 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
84 ; CHECK-NEXT: No successors
86 ; CHECK-NEXT: Live-out i32 %0 = vp<[[RESUME_1_P]]>
93 %0 = phi i32 [ 0, %entry ], [ %conv, %loop ]
94 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
95 %rem = srem i32 %0, %x
96 %gep = getelementptr i8, ptr %ptr, i32 %iv
97 %lv = load i8, ptr %gep
98 %conv = sext i8 %lv to i32
99 %add = add i32 %conv, %rem
100 %gep.dst = getelementptr i32, ptr %dst, i32 %iv
101 store i32 %add, ptr %gep.dst
102 %iv.next = add nsw i32 %iv, 1
103 %ec = icmp eq i32 %iv.next, 20001
104 br i1 %ec, label %exit, label %loop
110 define void @sink_replicate_region_2(i32 %x, i8 %y, ptr %ptr) optsize {
111 ; CHECK-LABEL: sink_replicate_region_2
112 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
113 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
114 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
115 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
116 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
118 ; CHECK-NEXT: vector.ph:
119 ; CHECK-NEXT: Successor(s): vector loop
121 ; CHECK-NEXT: <x1> vector loop: {
122 ; CHECK-NEXT: vector.body:
123 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
124 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
125 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
126 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
127 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
128 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
129 ; CHECK-NEXT: Successor(s): pred.store
131 ; CHECK-NEXT: <xVFxUF> pred.store: {
132 ; CHECK-NEXT: pred.store.entry:
133 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
134 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
136 ; CHECK-NEXT: pred.store.if:
137 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
138 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
139 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
140 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%rem>, ir<%recur.next>
141 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep>
142 ; CHECK-NEXT: Successor(s): pred.store.continue
144 ; CHECK-NEXT: pred.store.continue:
145 ; CHECK-NEXT: No successors
147 ; CHECK-NEXT: Successor(s): loop.1
149 ; CHECK-NEXT: loop.1:
150 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
151 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
152 ; CHECK-NEXT: No successors
154 ; CHECK-NEXT: Successor(s): middle.block
156 ; CHECK-NEXT: middle.block:
157 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%recur.next>, ir<1>
158 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
159 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
161 ; CHECK-NEXT: ir-bb<exit>
162 ; CHECK-NEXT: No successors
164 ; CHECK-NEXT: scalar.ph
165 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
166 ; CHECK-NEXT: No successors
168 ; CHECK-NEXT: Live-out i32 %recur = vp<[[RESUME_1_P]]>
175 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
176 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
177 %rem = srem i32 %recur, %x
178 %recur.next = sext i8 %y to i32
179 %add = add i32 %rem, %recur.next
180 %gep = getelementptr i32, ptr %ptr, i32 %iv
181 store i32 %add, ptr %gep
182 %iv.next = add nsw i32 %iv, 1
183 %ec = icmp eq i32 %iv.next, 20001
184 br i1 %ec, label %exit, label %loop
190 define i32 @sink_replicate_region_3_reduction(i32 %x, i8 %y, ptr %ptr) optsize {
191 ; CHECK-LABEL: sink_replicate_region_3_reduction
192 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
193 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
194 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
195 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
196 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
198 ; CHECK-NEXT: vector.ph:
199 ; CHECK-NEXT: Successor(s): vector loop
201 ; CHECK-NEXT: <x1> vector loop: {
202 ; CHECK-NEXT: vector.body:
203 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
204 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
205 ; CHECK-NEXT: WIDEN-REDUCTION-PHI ir<%and.red> = phi ir<1234>, ir<%and.red.next>
206 ; CHECK-NEXT: EMIT vp<[[WIDEN_CAN:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
207 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule vp<[[WIDEN_CAN]]>, vp<[[BTC]]>
208 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
209 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
210 ; CHECK-NEXT: Successor(s): pred.srem
212 ; CHECK-NEXT: <xVFxUF> pred.srem: {
213 ; CHECK-NEXT: pred.srem.entry:
214 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
215 ; CHECK-NEXT: Successor(s): pred.srem.if, pred.srem.continue
217 ; CHECK-NEXT: pred.srem.if:
218 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x> (S->V)
219 ; CHECK-NEXT: Successor(s): pred.srem.continue
221 ; CHECK-NEXT: pred.srem.continue:
222 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%rem>
223 ; CHECK-NEXT: No successors
225 ; CHECK-NEXT: Successor(s): loop.0
227 ; CHECK-NEXT: loop.0:
228 ; CHECK-NEXT: WIDEN ir<%add> = add vp<[[PRED]]>, ir<%recur.next>
229 ; CHECK-NEXT: WIDEN ir<%and.red.next> = and ir<%and.red>, ir<%add>
230 ; CHECK-NEXT: EMIT vp<[[SEL:%.+]]> = select vp<[[MASK]]>, ir<%and.red.next>, ir<%and.red>
231 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
232 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
233 ; CHECK-NEXT: No successors
235 ; CHECK-NEXT: Successor(s): middle.block
237 ; CHECK-NEXT: middle.block:
238 ; CHECK-NEXT: EMIT vp<[[RED_RES:%.+]]> = compute-reduction-result ir<%and.red>, vp<[[SEL]]>
239 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%recur.next>, ir<1>
240 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
241 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
243 ; CHECK-NEXT: ir-bb<exit>
244 ; CHECK-NEXT: No successors
246 ; CHECK-NEXT: scalar.ph
247 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
248 ; CHECK-NEXT: No successors
250 ; CHECK-NEXT: Live-out i32 %res = vp<[[RED_RES]]>
251 ; CHECK-NEXT: Live-out i32 %recur = vp<[[RESUME_1_P]]>
258 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
259 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
260 %and.red = phi i32 [ 1234, %entry ], [ %and.red.next, %loop ]
261 %rem = srem i32 %recur, %x
262 %recur.next = sext i8 %y to i32
263 %add = add i32 %rem, %recur.next
264 %and.red.next = and i32 %and.red, %add
265 %iv.next = add nsw i32 %iv, 1
266 %ec = icmp eq i32 %iv.next, 20001
267 br i1 %ec, label %exit, label %loop
270 %res = phi i32 [ %and.red.next, %loop ]
274 ; To sink the replicate region containing %rem, we need to split the block
275 ; containing %conv at the end, because %conv is the last recipe in the block.
276 define void @sink_replicate_region_4_requires_split_at_end_of_block(i32 %x, ptr %ptr, ptr noalias %dst) optsize {
277 ; CHECK-LABEL: sink_replicate_region_4_requires_split_at_end_of_block
278 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
279 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
280 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
281 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
282 ; CHECK-NEXT: Live-in ir<20001> = original trip-count
284 ; CHECK-NEXT: vector.ph:
285 ; CHECK-NEXT: Successor(s): vector loop
287 ; CHECK-NEXT: <x1> vector loop: {
288 ; CHECK-NEXT: vector.body:
289 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
290 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%0> = phi ir<0>, ir<%conv>
291 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
292 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
293 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
294 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
295 ; CHECK-NEXT: Successor(s): pred.load
297 ; CHECK-NEXT: <xVFxUF> pred.load: {
298 ; CHECK-NEXT: pred.load.entry:
299 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
300 ; CHECK-NEXT: Successor(s): pred.load.if, pred.load.continue
302 ; CHECK-NEXT: pred.load.if:
303 ; CHECK-NEXT: REPLICATE ir<%lv> = load ir<%gep> (S->V)
304 ; CHECK-NEXT: Successor(s): pred.load.continue
306 ; CHECK-NEXT: pred.load.continue:
307 ; CHECK-NEXT: PHI-PREDICATED-INSTRUCTION vp<[[PRED:%.+]]> = ir<%lv>
308 ; CHECK-NEXT: No successors
310 ; CHECK-NEXT: Successor(s): loop.0
312 ; CHECK-NEXT: loop.0:
313 ; CHECK-NEXT: WIDEN-CAST ir<%conv> = sext vp<[[PRED]]> to i32
314 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%0>, ir<%conv>
315 ; CHECK-NEXT: Successor(s): pred.store
317 ; CHECK: <xVFxUF> pred.store: {
318 ; CHECK-NEXT: pred.store.entry:
319 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
320 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
322 ; CHECK: pred.store.if:
323 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
324 ; CHECK-NEXT: REPLICATE ir<%lv.2> = load ir<%gep>
325 ; CHECK-NEXT: REPLICATE ir<%conv.lv.2> = sext ir<%lv.2>
326 ; CHECK-NEXT: REPLICATE ir<%add.1> = add ir<%conv>, ir<%rem>
327 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[STEPS]]>
328 ; CHECK-NEXT: REPLICATE ir<%add> = add ir<%add.1>, ir<%conv.lv.2>
329 ; CHECK-NEXT: REPLICATE store ir<%add>, ir<%gep.dst>
330 ; CHECK-NEXT: Successor(s): pred.store.continue
332 ; CHECK: pred.store.continue:
333 ; CHECK-NEXT: No successors
335 ; CHECK-NEXT: Successor(s): loop.3
338 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
339 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
340 ; CHECK-NEXT: No successors
342 ; CHECK-NEXT: Successor(s): middle.block
344 ; CHECK-NEXT: middle.block:
345 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%conv>, ir<1>
346 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
347 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
349 ; CHECK-NEXT: ir-bb<exit>
350 ; CHECK-NEXT: No successors
352 ; CHECK-NEXT: scalar.ph
353 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
354 ; CHECK-NEXT: No successors
356 ; CHECK-NEXT: Live-out i32 %0 = vp<[[RESUME_1_P]]>
363 %0 = phi i32 [ 0, %entry ], [ %conv, %loop ]
364 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
365 %gep = getelementptr i8, ptr %ptr, i32 %iv
366 %rem = srem i32 %0, %x
367 %lv = load i8, ptr %gep
368 %conv = sext i8 %lv to i32
369 %lv.2 = load i8, ptr %gep
370 %add.1 = add i32 %conv, %rem
371 %conv.lv.2 = sext i8 %lv.2 to i32
372 %add = add i32 %add.1, %conv.lv.2
373 %gep.dst = getelementptr i32, ptr %dst, i32 %iv
374 store i32 %add, ptr %gep.dst
375 %iv.next = add nsw i32 %iv, 1
376 %ec = icmp eq i32 %iv.next, 20001
377 br i1 %ec, label %exit, label %loop
383 ; Test case that requires sinking a recipe in a replicate region after another replicate region.
384 define void @sink_replicate_region_after_replicate_region(ptr %ptr, ptr noalias %dst.2, i32 %x, i8 %y) optsize {
385 ; CHECK-LABEL: sink_replicate_region_after_replicate_region
386 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
387 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
388 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
389 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
390 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
392 ; CHECK-NEXT: ir-bb<entry>:
393 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (1 smax (1 + (sext i8 %y to i32))<nsw>)
394 ; CHECK-NEXT: No successors
396 ; CHECK-NEXT: vector.ph:
397 ; CHECK-NEXT: Successor(s): vector loop
399 ; CHECK-NEXT: <x1> vector loop: {
400 ; CHECK-NEXT: vector.body:
401 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
402 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%recur> = phi ir<0>, ir<%recur.next>
403 ; CHECK-NEXT: WIDEN-INDUCTION %iv = phi 0, %iv.next, ir<1>
404 ; CHECK-NEXT: EMIT vp<[[MASK:%.+]]> = icmp ule ir<%iv>, vp<[[BTC]]>
405 ; CHECK-NEXT: WIDEN-CAST ir<%recur.next> = sext ir<%y> to i32
406 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%recur>, ir<%recur.next>
407 ; CHECK-NEXT: Successor(s): pred.store
409 ; CHECK-NEXT: <xVFxUF> pred.store: {
410 ; CHECK-NEXT: pred.store.entry:
411 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[MASK]]>
412 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
414 ; CHECK-NEXT: pred.store.if:
415 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
416 ; CHECK-NEXT: REPLICATE ir<%rem> = srem vp<[[SPLICE]]>, ir<%x>
417 ; CHECK-NEXT: REPLICATE ir<%rem.div> = sdiv ir<20>, ir<%rem>
418 ; CHECK-NEXT: REPLICATE ir<%gep> = getelementptr ir<%ptr>, vp<[[STEPS]]>
419 ; CHECK-NEXT: REPLICATE store ir<%rem.div>, ir<%gep>
420 ; CHECK-NEXT: REPLICATE ir<%gep.2> = getelementptr ir<%dst.2>, vp<[[STEPS]]>
421 ; CHECK-NEXT: REPLICATE store ir<%rem.div>, ir<%gep.2>
422 ; CHECK-NEXT: Successor(s): pred.store.continue
424 ; CHECK-NEXT: pred.store.continue:
425 ; CHECK-NEXT: No successors
427 ; CHECK-NEXT: Successor(s): loop.3
429 ; CHECK-NEXT: loop.3:
430 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
431 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
432 ; CHECK-NEXT: No successors
434 ; CHECK-NEXT: Successor(s): middle.block
436 ; CHECK-NEXT: middle.block:
437 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%recur.next>, ir<1>
438 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
439 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
441 ; CHECK-NEXT: ir-bb<exit>
442 ; CHECK-NEXT: No successors
444 ; CHECK-NEXT: scalar.ph
445 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
446 ; CHECK-NEXT: No successors
448 ; CHECK-NEXT: Live-out i32 %recur = vp<[[RESUME_1_P]]>
454 loop: ; preds = %loop, %entry
455 %recur = phi i32 [ 0, %entry ], [ %recur.next, %loop ]
456 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
457 %rem = srem i32 %recur, %x
458 %rem.div = sdiv i32 20, %rem
459 %recur.next = sext i8 %y to i32
460 %gep = getelementptr i32, ptr %ptr, i32 %iv
461 store i32 %rem.div, ptr %gep
462 %gep.2 = getelementptr i32, ptr %dst.2, i32 %iv
463 store i32 %rem.div, ptr %gep.2
464 %iv.next = add nsw i32 %iv, 1
465 %C = icmp sgt i32 %iv.next, %recur.next
466 br i1 %C, label %exit, label %loop
468 exit: ; preds = %loop
472 define void @need_new_block_after_sinking_pr56146(i32 %x, ptr %src, ptr noalias %dst) {
473 ; CHECK-LABEL: need_new_block_after_sinking_pr56146
474 ; CHECK: VPlan 'Initial VPlan for VF={2},UF>=1' {
475 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
476 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
477 ; CHECK-NEXT: Live-in vp<[[BTC:%.+]]> = backedge-taken count
478 ; CHECK-NEXT: Live-in ir<3> = original trip-count
480 ; CHECK-NEXT: vector.ph:
481 ; CHECK-NEXT: Successor(s): vector loop
483 ; CHECK-NEXT: <x1> vector loop: {
484 ; CHECK-NEXT: vector.body:
485 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION
486 ; CHECK-NEXT: FIRST-ORDER-RECURRENCE-PHI ir<%.pn> = phi ir<0>, ir<[[L:%.+]]>
487 ; CHECK-NEXT: vp<[[DERIVED_IV:%.+]]> = DERIVED-IV ir<2> + vp<[[CAN_IV]]> * ir<1>
488 ; CHECK-NEXT: EMIT vp<[[WIDE_IV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[CAN_IV]]>
489 ; CHECK-NEXT: EMIT vp<[[CMP:%.+]]> = icmp ule vp<[[WIDE_IV]]>, vp<[[BTC]]>
490 ; CHECK-NEXT: CLONE ir<[[L]]> = load ir<%src>
491 ; CHECK-NEXT: EMIT vp<[[SPLICE:%.+]]> = first-order splice ir<%.pn>, ir<[[L]]>
492 ; CHECK-NEXT: Successor(s): pred.store
494 ; CHECK-NEXT: <xVFxUF> pred.store: {
495 ; CHECK-NEXT: pred.store.entry:
496 ; CHECK-NEXT: BRANCH-ON-MASK vp<[[CMP]]>
497 ; CHECK-NEXT: Successor(s): pred.store.if, pred.store.continue
499 ; CHECK-NEXT: pred.store.if:
500 ; CHECK-NEXT: REPLICATE ir<%val> = sdiv vp<[[SPLICE]]>, ir<%x>
501 ; CHECK-NEXT: vp<[[SCALAR_STEPS:%.+]]> = SCALAR-STEPS vp<[[DERIVED_IV]]>, ir<1>
502 ; CHECK-NEXT: REPLICATE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[SCALAR_STEPS]]>
503 ; CHECK-NEXT: REPLICATE store ir<%val>, ir<%gep.dst>
504 ; CHECK-NEXT: Successor(s): pred.store.continue
506 ; CHECK-NEXT: pred.store.continue:
507 ; CHECK-NEXT: No successors
509 ; CHECK-NEXT: Successor(s): loop.1
511 ; CHECK-NEXT: loop.1:
512 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add vp<[[CAN_IV]]>, vp<[[VFxUF]]>
513 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
514 ; CHECK-NEXT: No successors
516 ; CHECK-NEXT: Successor(s): middle.block
518 ; CHECK-NEXT: middle.block:
519 ; CHECK-NEXT: EMIT vp<[[RESUME_1:%.+]]> = extract-from-end ir<%l>, ir<1>
520 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
521 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
523 ; CHECK-NEXT: ir-bb<exit>
524 ; CHECK-NEXT: No successors
526 ; CHECK-NEXT: scalar.ph
527 ; CHECK-NEXT: EMIT vp<[[RESUME_1_P:%.*]]> = resume-phi vp<[[RESUME_1]]>, ir<0>
528 ; CHECK-NEXT: No successors
530 ; CHECK-NEXT: Live-out i32 %.pn = vp<[[RESUME_1_P]]>
537 %iv = phi i64 [ 2, %entry ], [ %iv.next, %loop ]
538 %.pn = phi i32 [ 0, %entry ], [ %l, %loop ]
539 %val = sdiv i32 %.pn, %x
540 %l = load i32, ptr %src, align 4
541 %gep.dst = getelementptr i32, ptr %dst, i64 %iv
542 store i32 %val, ptr %gep.dst
543 %iv.next = add nuw nsw i64 %iv, 1
544 %ec = icmp ugt i64 %iv, 3
545 br i1 %ec, label %exit, label %loop