@@ -2419,25 +2419,19 @@ bool LoopAccessInfo::isAnalyzableEarlyExitLoop() {
24192419 if (ExitingBlocks.size () < 2 )
24202420 return false ;
24212421
2422- SmallVector<BasicBlock *, 4 > ExactExitingBlocks ;
2423- PSE->getSE ()->getExactExitingBlocks (TheLoop, &ExactExitingBlocks );
2422+ SmallVector<BasicBlock *, 4 > CountableExitingBBs ;
2423+ PSE->getSE ()->getCountableExitingBlocks (TheLoop, &CountableExitingBBs );
24242424
24252425 // We only support one speculative early exit.
2426- if ((ExitingBlocks.size () - ExactExitingBlocks .size ()) > 1 )
2426+ if ((ExitingBlocks.size () - CountableExitingBBs .size ()) > 1 )
24272427 return false ;
24282428
24292429 // There could be multiple exiting blocks with an exact exit-not-taken
24302430 // count. Find the speculative early exit block, i.e. the one with an
24312431 // unknown count.
24322432 BasicBlock *TmpBB = nullptr ;
24332433 for (BasicBlock *BB1 : ExitingBlocks) {
2434- bool Found = false ;
2435- for (BasicBlock *BB2 : ExactExitingBlocks)
2436- if (BB1 == BB2) {
2437- Found = true ;
2438- break ;
2439- }
2440- if (!Found) {
2434+ if (!is_contained (CountableExitingBBs, BB1)) {
24412435 TmpBB = BB1;
24422436 break ;
24432437 }
@@ -2468,7 +2462,7 @@ bool LoopAccessInfo::isAnalyzableEarlyExitLoop() {
24682462 }
24692463 assert (SpeculativeEarlyExitBB &&
24702464 " Expected to find speculative early exit block" );
2471- CountableEarlyExitBlocks = std::move (ExactExitingBlocks );
2465+ CountableEarlyExitingBlocks = std::move (CountableExitingBBs );
24722466
24732467 return true ;
24742468}
@@ -2626,9 +2620,11 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
26262620 if (I.mayWriteToMemory ()) {
26272621 auto *St = dyn_cast<StoreInst>(&I);
26282622 if (SpeculativeEarlyExitingBB) {
2629- recordAnalysis (" CantVectorizeInstruction" , St)
2630- << " cannot vectorize stores in early exit loop" ;
2631- LLVM_DEBUG (dbgs () << " LAA: Found a store in early exit loop.\n " );
2623+ recordAnalysis (" CantVectorizeInstruction" , &I)
2624+ << " cannot vectorize instructions that write to memory in early "
2625+ << " exit loop" ;
2626+ LLVM_DEBUG (dbgs () << " LAA: Found an instruction that writes to "
2627+ << " memory in early exit loop.\n " );
26322628 HasComplexWorkInEarlyExitLoop = true ;
26332629 continue ;
26342630 }
@@ -2784,7 +2780,6 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
27842780 Accesses.buildDependenceSets ();
27852781
27862782 if (SpeculativeEarlyExitingBB) {
2787- assert (!Stores.size () && " Did not expect stores in an early exit loop!" );
27882783 LoopMayFault = Accesses.mayFault ();
27892784 CanVecMem = true ;
27902785 return ;
0 commit comments