@@ -352,8 +352,10 @@ std::unique_ptr<VPlan> PlainCFGBuilder::buildPlainCFG(
352
352
Plan->getEntry ()->setOneSuccessor (getOrCreateVPBB (TheLoop->getHeader ()));
353
353
Plan->getEntry ()->setPlan (&*Plan);
354
354
355
- // Fix VPlan loop-closed-ssa exit phi's by add incoming operands to the
355
+ // Fix VPlan loop-closed-ssa exit phi's by adding incoming operands to the
356
356
// VPIRInstructions wrapping them.
357
+ // Note that the operand order may need adjusting when predecessors are added,
358
+ // if an exit block has multiple predecessor.
357
359
for (auto *EB : Plan->getExitBlocks ()) {
358
360
for (VPRecipeBase &R : EB->phis ()) {
359
361
auto *PhiR = cast<VPIRPhi>(&R);
@@ -476,6 +478,17 @@ void VPlanTransforms::createLoopRegions(VPlan &Plan, Type *InductionTy,
476
478
477
479
VPBasicBlock *ScalarPH = Plan.createVPBasicBlock (" scalar.ph" );
478
480
VPBlockUtils::connectBlocks (ScalarPH, Plan.getScalarHeader ());
481
+
482
+ // If needed, add a check in the middle block to see if we have completed
483
+ // all of the iterations in the first vector loop. Three cases:
484
+ // 1) If we require a scalar epilogue, there is no conditional branch as
485
+ // we unconditionally branch to the scalar preheader. Remove the recipes
486
+ // from the exit blocks.
487
+ // 2) If (N - N%VF) == N, then we *don't* need to run the remainder.
488
+ // Thus if tail is to be folded, we know we don't need to run the
489
+ // remainder and we can set the condition to true.
490
+ // 3) Otherwise, construct a runtime check.
491
+
479
492
if (!RequiresScalarEpilogueCheck) {
480
493
VPBlockUtils::connectBlocks (MiddleVPBB, ScalarPH);
481
494
// The exit blocks are unreachable, remove their recipes to make sure no
@@ -487,14 +500,6 @@ void VPlanTransforms::createLoopRegions(VPlan &Plan, Type *InductionTy,
487
500
return ;
488
501
}
489
502
490
- // If needed, add a check in the middle block to see if we have completed
491
- // all of the iterations in the first vector loop. Three cases:
492
- // 1) If (N - N%VF) == N, then we *don't* need to run the remainder.
493
- // Thus if tail is to be folded, we know we don't need to run the
494
- // remainder and we can set the condition to true.
495
- // 2) If we require a scalar epilogue, there is no conditional branch as
496
- // we unconditionally branch to the scalar preheader. Do nothing.
497
- // 3) Otherwise, construct a runtime check.
498
503
BasicBlock *IRExitBlock = TheLoop->getUniqueLatchExitBlock ();
499
504
auto *VPExitBlock = Plan.getExitBlock (IRExitBlock);
500
505
// The connection order corresponds to the operands of the conditional branch.
0 commit comments