@@ -206,5 +206,209 @@ for.end:
206
206
ret i32 %add
207
207
}
208
208
209
+ define i32 @cond_add_pred (ptr %a , i64 %n , i32 %start ) {
210
+ ; IF-EVL-OUTLOOP: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
211
+ ; IF-EVL-OUTLOOP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
212
+ ; IF-EVL-OUTLOOP-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
213
+ ; IF-EVL-OUTLOOP-NEXT: Live-in vp<[[BTC:%[0-9]+]]> = backedge-taken count
214
+ ; IF-EVL-OUTLOOP-NEXT: Live-in ir<%n> = original trip-count
215
+ ; IF-EVL-OUTLOOP-EMPTY:
216
+ ; IF-EVL-OUTLOOP: vector.ph:
217
+ ; IF-EVL-OUTLOOP-NEXT: Successor(s): vector loop
218
+ ; IF-EVL-OUTLOOP-EMPTY:
219
+ ; IF-EVL-OUTLOOP-NEXT: <x1> vector loop: {
220
+ ; IF-EVL-OUTLOOP-NEXT: vector.body:
221
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
222
+ ; IF-EVL-OUTLOOP-NEXT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<[[EVL_PHI:%[0-9]+]]> = phi ir<0>, vp<[[IV_NEXT:%[0-9]+]]>
223
+ ; IF-EVL-OUTLOOP-NEXT: WIDEN-REDUCTION-PHI ir<[[RDX_PHI:%.+]]> = phi ir<%start>, ir<[[RDX_NEXT:%.+]]>
224
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[EVL:%.+]]> = EXPLICIT-VECTOR-LENGTH vp<[[EVL_PHI]]>, ir<%n>
225
+ ; IF-EVL-OUTLOOP-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[EVL_PHI]]>, ir<1>
226
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[WIV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[EVL_PHI]]>
227
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[HEADER_MASK:%.+]]> = icmp ule vp<[[WIV]]>, vp<[[BTC]]>
228
+ ; IF-EVL-OUTLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
229
+ ; IF-EVL-OUTLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
230
+ ; IF-EVL-OUTLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = vp.load vp<[[PTR1]]>, vp<[[EVL]]>
231
+ ; IF-EVL-OUTLOOP-NEXT: WIDEN ir<[[COND:%.+]]> = icmp sgt ir<[[LD1]]>, ir<3>
232
+ ; IF-EVL-OUTLOOP-NEXT: WIDEN ir<[[ADD:%.+]]> = add ir<[[RDX_PHI]]>, ir<[[LD1]]>
233
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[NOT_COND:%.+]]> = not ir<[[COND]]>
234
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[BLEND_MASK:%.+]]> = logical-and vp<[[HEADER_MASK]]>, vp<[[NOT_COND]]>
235
+ ; IF-EVL-OUTLOOP-NEXT: BLEND ir<[[BLEND_ADD:%.+]]> = ir<[[ADD]]> ir<[[RDX_PHI]]>/vp<[[BLEND_MASK]]>
236
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[RDX_SELECT:%.+]]> = merge-until-pivot ir<true>, ir<[[BLEND_ADD]]>, ir<[[RDX_PHI]]>, vp<[[EVL]]>
237
+ ; IF-EVL-OUTLOOP-NEXT: SCALAR-CAST vp<[[CAST:%[0-9]+]]> = zext vp<[[EVL]]> to i64
238
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[IV_NEXT]]> = add vp<[[CAST]]>, vp<[[EVL_PHI]]>
239
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%[0-9]+]]> = add vp<[[IV]]>, vp<[[VFUF]]>
240
+ ; IF-EVL-OUTLOOP-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]>
241
+ ; IF-EVL-OUTLOOP-NEXT: No successors
242
+ ; IF-EVL-OUTLOOP-NEXT: }
243
+ ; IF-EVL-OUTLOOP-NEXT: Successor(s): middle.block
244
+ ; IF-EVL-OUTLOOP-EMPTY:
245
+ ; IF-EVL-OUTLOOP-NEXT: middle.block:
246
+ ; IF-EVL-OUTLOOP-NEXT: EMIT vp<[[RDX:%.+]]> = compute-reduction-result ir<[[RDX_PHI]]>, vp<[[RDX_SELECT]]>
247
+ ; IF-EVL-OUTLOOP-NEXT: EMIT branch-on-cond ir<true>
248
+ ; IF-EVL-OUTLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
249
+ ; IF-EVL-OUTLOOP-EMPTY:
250
+ ; IF-EVL-OUTLOOP-NEXT: ir-bb<for.end>:
251
+ ; IF-EVL-OUTLOOP-NEXT: No successors
252
+ ; IF-EVL-OUTLOOP-EMPTY:
253
+ ; IF-EVL-OUTLOOP-NEXT: scalar.ph:
254
+ ; IF-EVL-OUTLOOP-NEXT: No successors
255
+ ; IF-EVL-OUTLOOP-EMPTY:
256
+ ; IF-EVL-OUTLOOP-NEXT: Live-out i32 %rdx.add.lcssa = vp<[[RDX]]>
257
+ ; IF-EVL-OUTLOOP-NEXT: }
258
+ ;
259
+
260
+ ; IF-EVL-INLOOP: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
261
+ ; IF-EVL-INLOOP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
262
+ ; IF-EVL-INLOOP-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
263
+ ; IF-EVL-INLOOP-NEXT: Live-in vp<[[BTC:%[0-9]+]]> = backedge-taken count
264
+ ; IF-EVL-INLOOP-NEXT: Live-in ir<%n> = original trip-count
265
+ ; IF-EVL-INLOOP-EMPTY:
266
+ ; IF-EVL-INLOOP: vector.ph:
267
+ ; IF-EVL-INLOOP-NEXT: Successor(s): vector loop
268
+ ; IF-EVL-INLOOP-EMPTY:
269
+ ; IF-EVL-INLOOP-NEXT: <x1> vector loop: {
270
+ ; IF-EVL-INLOOP-NEXT: vector.body:
271
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
272
+ ; IF-EVL-INLOOP-NEXT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<[[EVL_PHI:%[0-9]+]]> = phi ir<0>, vp<[[IV_NEXT:%[0-9]+]]>
273
+ ; IF-EVL-INLOOP-NEXT: WIDEN-REDUCTION-PHI ir<[[RDX_PHI:%.+]]> = phi ir<%start>, ir<[[RDX_NEXT:%.+]]>
274
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[EVL:%.+]]> = EXPLICIT-VECTOR-LENGTH vp<[[EVL_PHI]]>, ir<%n>
275
+ ; IF-EVL-INLOOP-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[EVL_PHI]]>, ir<1>
276
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[WIV:%.+]]> = WIDEN-CANONICAL-INDUCTION vp<[[EVL_PHI]]>
277
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[HEADER_MASK:%.+]]> = icmp ule vp<[[WIV]]>, vp<[[BTC]]>
278
+ ; IF-EVL-INLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
279
+ ; IF-EVL-INLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
280
+ ; IF-EVL-INLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = vp.load vp<[[PTR1]]>, vp<[[EVL]]>
281
+ ; IF-EVL-INLOOP-NEXT: WIDEN ir<[[COND:%.+]]> = icmp sgt ir<[[LD1]]>, ir<3>
282
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[MASK:%.+]]> = logical-and vp<[[HEADER_MASK]]>, ir<[[COND]]>
283
+ ; IF-EVL-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + vp.reduce.add (ir<[[LD1]]>, vp<[[EVL]]>, vp<[[MASK]]>)
284
+ ; IF-EVL-INLOOP-NEXT: SCALAR-CAST vp<[[CAST:%[0-9]+]]> = zext vp<[[EVL]]> to i64
285
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[IV_NEXT]]> = add vp<[[CAST]]>, vp<[[EVL_PHI]]>
286
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%[0-9]+]]> = add vp<[[IV]]>, vp<[[VFUF]]>
287
+ ; IF-EVL-INLOOP-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]>
288
+ ; IF-EVL-INLOOP-NEXT: No successors
289
+ ; IF-EVL-INLOOP-NEXT: }
290
+ ; IF-EVL-INLOOP-NEXT: Successor(s): middle.block
291
+ ; IF-EVL-INLOOP-EMPTY:
292
+ ; IF-EVL-INLOOP-NEXT: middle.block:
293
+ ; IF-EVL-INLOOP-NEXT: EMIT vp<[[RDX:%.+]]> = compute-reduction-result ir<[[RDX_PHI]]>, ir<[[ADD]]>
294
+ ; IF-EVL-INLOOP-NEXT: EMIT branch-on-cond ir<true>
295
+ ; IF-EVL-INLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
296
+ ; IF-EVL-INLOOP-EMPTY:
297
+ ; IF-EVL-INLOOP-NEXT: ir-bb<for.end>:
298
+ ; IF-EVL-INLOOP-NEXT: No successors
299
+ ; IF-EVL-INLOOP-EMPTY:
300
+ ; IF-EVL-INLOOP-NEXT: scalar.ph:
301
+ ; IF-EVL-INLOOP-NEXT: No successors
302
+ ; IF-EVL-INLOOP-EMPTY:
303
+ ; IF-EVL-INLOOP-NEXT: Live-out i32 %rdx.add.lcssa = vp<[[RDX]]>
304
+ ; IF-EVL-INLOOP-NEXT: }
305
+ ;
306
+
307
+ ; NO-VP-OUTLOOP: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF>=1' {
308
+ ; NO-VP-OUTLOOP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
309
+ ; NO-VP-OUTLOOP-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
310
+ ; NO-VP-OUTLOOP-NEXT: Live-in ir<%n> = original trip-count
311
+ ; NO-VP-OUTLOOP-EMPTY:
312
+ ; NO-VP-OUTLOOP: vector.ph:
313
+ ; NO-VP-OUTLOOP-NEXT: Successor(s): vector loop
314
+ ; NO-VP-OUTLOOP-EMPTY:
315
+ ; NO-VP-OUTLOOP-NEXT: <x1> vector loop: {
316
+ ; NO-VP-OUTLOOP-NEXT: vector.body:
317
+ ; NO-VP-OUTLOOP-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
318
+ ; NO-VP-OUTLOOP-NEXT: WIDEN-REDUCTION-PHI ir<[[RDX_PHI:%.+]]> = phi ir<%start>, ir<[[RDX_NEXT:%.+]]>
319
+ ; NO-VP-OUTLOOP-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[IV]]>, ir<1>
320
+ ; NO-VP-OUTLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
321
+ ; NO-VP-OUTLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
322
+ ; NO-VP-OUTLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = load vp<[[PTR1]]>
323
+ ; NO-VP-OUTLOOP-NEXT: WIDEN ir<[[COND:%.+]]> = icmp sgt ir<[[LD1]]>, ir<3>
324
+ ; NO-VP-OUTLOOP-NEXT: WIDEN ir<[[ADD:%.+]]> = add ir<[[RDX_PHI]]>, ir<[[LD1]]>
325
+ ; NO-VP-OUTLOOP-NEXT: EMIT vp<[[NOT_COND:%.+]]> = not ir<[[COND]]>
326
+ ; NO-VP-OUTLOOP-NEXT: BLEND ir<[[BLEND_ADD:%.+]]> = ir<[[ADD]]> ir<[[RDX_PHI]]>/vp<[[NOT_COND]]>
327
+ ; NO-VP-OUTLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%[0-9]+]]> = add nuw vp<[[IV]]>, vp<[[VFUF]]>
328
+ ; NO-VP-OUTLOOP-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]>
329
+ ; NO-VP-OUTLOOP-NEXT: No successors
330
+ ; NO-VP-OUTLOOP-NEXT: }
331
+ ; NO-VP-OUTLOOP-NEXT: Successor(s): middle.block
332
+ ; NO-VP-OUTLOOP-EMPTY:
333
+ ; NO-VP-OUTLOOP-NEXT: middle.block:
334
+ ; NO-VP-OUTLOOP-NEXT: EMIT vp<[[RDX:%.+]]> = compute-reduction-result ir<[[RDX_PHI]]>, ir<[[BLEND_ADD]]>
335
+ ; NO-VP-OUTLOOP-NEXT: EMIT vp<[[BOC:%.+]]> = icmp eq ir<%n>, vp<[[VTC]]>
336
+ ; NO-VP-OUTLOOP-NEXT: EMIT branch-on-cond vp<[[BOC]]>
337
+ ; NO-VP-OUTLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
338
+ ; NO-VP-OUTLOOP-EMPTY:
339
+ ; NO-VP-OUTLOOP-NEXT: ir-bb<for.end>:
340
+ ; NO-VP-OUTLOOP-NEXT: No successors
341
+ ; NO-VP-OUTLOOP-EMPTY:
342
+ ; NO-VP-OUTLOOP-NEXT: scalar.ph:
343
+ ; NO-VP-OUTLOOP-NEXT: No successors
344
+ ; NO-VP-OUTLOOP-EMPTY:
345
+ ; NO-VP-OUTLOOP-NEXT: Live-out i32 %rdx.add.lcssa = vp<[[RDX]]>
346
+ ; NO-VP-OUTLOOP-NEXT: }
347
+ ;
348
+
349
+ ; NO-VP-INLOOP: VPlan 'Initial VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF>=1' {
350
+ ; NO-VP-INLOOP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
351
+ ; NO-VP-INLOOP-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
352
+ ; NO-VP-INLOOP-NEXT: Live-in ir<%n> = original trip-count
353
+ ; NO-VP-INLOOP-EMPTY:
354
+ ; NO-VP-INLOOP: vector.ph:
355
+ ; NO-VP-INLOOP-NEXT: Successor(s): vector loop
356
+ ; NO-VP-INLOOP-EMPTY:
357
+ ; NO-VP-INLOOP-NEXT: <x1> vector loop: {
358
+ ; NO-VP-INLOOP-NEXT: vector.body:
359
+ ; NO-VP-INLOOP-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
360
+ ; NO-VP-INLOOP-NEXT: WIDEN-REDUCTION-PHI ir<[[RDX_PHI:%.+]]> = phi ir<%start>, ir<[[RDX_NEXT:%.+]]>
361
+ ; NO-VP-INLOOP-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[IV]]>, ir<1>
362
+ ; NO-VP-INLOOP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
363
+ ; NO-VP-INLOOP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
364
+ ; NO-VP-INLOOP-NEXT: WIDEN ir<[[LD1:%.+]]> = load vp<[[PTR1]]>
365
+ ; NO-VP-INLOOP-NEXT: WIDEN ir<[[COND:%.+]]> = icmp sgt ir<[[LD1]]>, ir<3>
366
+ ; NO-VP-INLOOP-NEXT: REDUCE ir<[[ADD:%.+]]> = ir<[[RDX_PHI]]> + reduce.add (ir<[[LD1]]>, ir<[[COND]]>)
367
+ ; NO-VP-INLOOP-NEXT: EMIT vp<[[IV_NEXT_EXIT:%[0-9]+]]> = add nuw vp<[[IV]]>, vp<[[VFUF]]>
368
+ ; NO-VP-INLOOP-NEXT: EMIT branch-on-count vp<[[IV_NEXT_EXIT]]>, vp<[[VTC]]>
369
+ ; NO-VP-INLOOP-NEXT: No successors
370
+ ; NO-VP-INLOOP-NEXT: }
371
+ ; NO-VP-INLOOP-NEXT: Successor(s): middle.block
372
+ ; NO-VP-INLOOP-EMPTY:
373
+ ; NO-VP-INLOOP-NEXT: middle.block:
374
+ ; NO-VP-INLOOP-NEXT: EMIT vp<[[RDX:%.+]]> = compute-reduction-result ir<[[RDX_PHI]]>, ir<[[ADD]]>
375
+ ; NO-VP-INLOOP-NEXT: EMIT vp<[[BOC:%.+]]> = icmp eq ir<%n>, vp<[[VTC]]>
376
+ ; NO-VP-INLOOP-NEXT: EMIT branch-on-cond vp<[[BOC]]>
377
+ ; NO-VP-INLOOP-NEXT: Successor(s): ir-bb<for.end>, scalar.ph
378
+ ; NO-VP-INLOOP-EMPTY:
379
+ ; NO-VP-INLOOP-NEXT: ir-bb<for.end>:
380
+ ; NO-VP-INLOOP-NEXT: No successors
381
+ ; NO-VP-INLOOP-EMPTY:
382
+ ; NO-VP-INLOOP-NEXT: scalar.ph:
383
+ ; NO-VP-INLOOP-NEXT: No successors
384
+ ; NO-VP-INLOOP-EMPTY:
385
+ ; NO-VP-INLOOP-NEXT: Live-out i32 %rdx.add.lcssa = vp<[[RDX]]>
386
+ ; NO-VP-INLOOP-NEXT: }
387
+ ;
388
+ entry:
389
+ br label %for.body
390
+
391
+ for.body:
392
+ %iv = phi i64 [ 0 , %entry ], [ %iv.next , %for.inc ]
393
+ %rdx = phi i32 [ %start , %entry ], [ %rdx.add , %for.inc ]
394
+ %arrayidx = getelementptr inbounds i32 , ptr %a , i64 %iv
395
+ %0 = load i32 , ptr %arrayidx , align 4
396
+ %cmp = icmp sgt i32 %0 , 3
397
+ br i1 %cmp , label %if.then , label %for.inc
398
+
399
+ if.then:
400
+ %add.pred = add nsw i32 %rdx , %0
401
+ br label %for.inc
402
+
403
+ for.inc:
404
+ %rdx.add = phi i32 [ %add.pred , %if.then ], [ %rdx , %for.body ]
405
+ %iv.next = add nuw nsw i64 %iv , 1
406
+ %exitcond.not = icmp eq i64 %iv.next , %n
407
+ br i1 %exitcond.not , label %for.end , label %for.body , !llvm.loop !0
408
+
409
+ for.end:
410
+ ret i32 %rdx.add
411
+ }
412
+
209
413
!0 = distinct !{!0 , !1 }
210
414
!1 = !{!"llvm.loop.vectorize.enable" , i1 true }
0 commit comments