@@ -178,7 +178,8 @@ VPBasicBlock *PlainCFGBuilder::getOrCreateVPBB(BasicBlock *BB) {
178
178
VPBasicBlock *VPBB = Plan.createVPBasicBlock (Name);
179
179
BB2VPBB[BB] = VPBB;
180
180
181
- // Get or create a region for the loop containing BB.
181
+ // Get or create a region for the loop containing BB, except for the top
182
+ // region of TheLoop which is created later.
182
183
Loop *LoopOfBB = LI->getLoopFor (BB);
183
184
if (!LoopOfBB || LoopOfBB == TheLoop || !doesContainLoop (LoopOfBB, TheLoop))
184
185
return VPBB;
@@ -194,12 +195,8 @@ VPBasicBlock *PlainCFGBuilder::getOrCreateVPBB(BasicBlock *BB) {
194
195
assert (!RegionOfVPBB &&
195
196
" First visit of a header basic block expects to register its region." );
196
197
// Handle a header - take care of its Region.
197
- if (LoopOfBB == TheLoop) {
198
- RegionOfVPBB = Plan.getVectorLoopRegion ();
199
- } else {
200
- RegionOfVPBB = Plan.createVPRegionBlock (Name.str (), false /* isReplicator*/ );
201
- RegionOfVPBB->setParent (Loop2Region[LoopOfBB->getParentLoop ()]);
202
- }
198
+ RegionOfVPBB = Plan.createVPRegionBlock (Name.str (), false /* isReplicator*/ );
199
+ RegionOfVPBB->setParent (Loop2Region[LoopOfBB->getParentLoop ()]);
203
200
RegionOfVPBB->setEntry (VPBB);
204
201
Loop2Region[LoopOfBB] = RegionOfVPBB;
205
202
return VPBB;
@@ -383,11 +380,10 @@ void PlainCFGBuilder::buildPlainCFG(
383
380
// Set VPBB predecessors in the same order as they are in the incoming BB.
384
381
if (!isHeaderBB (BB, LoopForBB)) {
385
382
setVPBBPredsFromBB (VPBB, BB);
386
- } else {
387
- // BB is a loop header, set the predecessor for the region, except for the
388
- // top region, whose predecessor was set when creating VPlan's skeleton.
389
- if (LoopForBB != TheLoop)
390
- setRegionPredsFromBB (Region, BB);
383
+ } else if (Region) {
384
+ // BB is a loop header and there's a corresponding region , set the
385
+ // predecessor for it.
386
+ setRegionPredsFromBB (Region, BB);
391
387
}
392
388
393
389
// Create VPInstructions for BB.
@@ -427,22 +423,15 @@ void PlainCFGBuilder::buildPlainCFG(
427
423
VPBasicBlock *Successor0 = getOrCreateVPBB (IRSucc0);
428
424
VPBasicBlock *Successor1 = getOrCreateVPBB (IRSucc1);
429
425
if (BB == LoopForBB->getLoopLatch ()) {
430
- // For a latch we need to set the successor of the region rather
431
- // than that
432
- // of VPBB and it should be set to the exit, i.e., non-header
433
- // successor,
434
- // except for the top region, whose successor was set when creating
435
- // VPlan's skeleton.
426
+ // For a latch we need to set the successor of the region rather than that
427
+ // of VPBB and it should be set to the exit, i.e., non-header successor,
428
+ // except for the top region, which is handled elsewhere.
436
429
assert (LoopForBB != TheLoop &&
437
430
" Latch of the top region should have been handled earlier" );
438
431
Region->setOneSuccessor (isHeaderVPBB (Successor0) ? Successor1
439
432
: Successor0);
440
433
Region->setExiting (VPBB);
441
434
continue ;
442
-
443
- VPBasicBlock *HeaderVPBB = getOrCreateVPBB (LoopForBB->getHeader ());
444
- VPBlockUtils::connectBlocks (VPBB, HeaderVPBB);
445
- continue ;
446
435
}
447
436
448
437
// Don't connect any blocks outside the current loop except the latch for
0 commit comments