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