@@ -478,32 +478,23 @@ void VPIRBasicBlock::execute(VPTransformState *State) {
478
478
479
479
void VPBasicBlock::execute (VPTransformState *State) {
480
480
bool Replica = bool (State->Lane );
481
- VPBasicBlock *PrevVPBB = State->CFG .PrevVPBB ;
482
- VPBlockBase *SingleHPred = nullptr ;
483
481
BasicBlock *NewBB = State->CFG .PrevBB ; // Reuse it if possible.
484
482
485
- auto IsLoopRegion = [](VPBlockBase *BB) {
486
- auto *R = dyn_cast <VPRegionBlock>(BB);
487
- return R && ! R->isReplicator ();
483
+ auto IsReplicateRegion = [](VPBlockBase *BB) {
484
+ auto *R = dyn_cast_or_null <VPRegionBlock>(BB);
485
+ return R && R->isReplicator ();
488
486
};
489
487
490
488
// 1. Create an IR basic block.
491
- if (PrevVPBB && /* A */
492
- !((SingleHPred = getSingleHierarchicalPredecessor ()) &&
493
- SingleHPred->getExitingBasicBlock () == PrevVPBB &&
494
- PrevVPBB->getSingleHierarchicalSuccessor () &&
495
- (SingleHPred->getParent () == getEnclosingLoopRegion () &&
496
- !IsLoopRegion (SingleHPred))) && /* B */
497
- !(Replica && getPredecessors ().empty ())) { /* C */
498
- // The last IR basic block is reused, as an optimization, in three cases:
499
- // A. the first VPBB reuses the loop pre-header BB - when PrevVPBB is null;
500
- // B. when the current VPBB has a single (hierarchical) predecessor which
501
- // is PrevVPBB and the latter has a single (hierarchical) successor which
502
- // both are in the same non-replicator region; and
503
- // C. when the current VPBB is an entry of a region replica - where PrevVPBB
504
- // is the exiting VPBB of this region from a previous instance, or the
505
- // predecessor of this region.
506
-
489
+ if (this == getPlan ()->getVectorPreheader () ||
490
+ (Replica && this == getParent ()->getEntry ()) ||
491
+ IsReplicateRegion (getSingleHierarchicalPredecessor ())) {
492
+ // Reuse the previous basic block if the current VPBB is either
493
+ // * the vector preheader,
494
+ // * the entry to a replicate region, or
495
+ // * the exit of a replicate region.
496
+ State->CFG .VPBB2IRBB [this ] = NewBB;
497
+ } else {
507
498
NewBB = createEmptyBasicBlock (State->CFG );
508
499
509
500
State->Builder .SetInsertPoint (NewBB);
@@ -518,8 +509,6 @@ void VPBasicBlock::execute(VPTransformState *State) {
518
509
State->CFG .PrevBB = NewBB;
519
510
State->CFG .VPBB2IRBB [this ] = NewBB;
520
511
connectToPredecessors (State->CFG );
521
- } else {
522
- State->CFG .VPBB2IRBB [this ] = NewBB;
523
512
}
524
513
525
514
// 2. Fill the IR basic block with IR instructions.
0 commit comments