@@ -1665,7 +1665,7 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
1665
1665
1666
1666
// Keep a record of all the exiting blocks.
1667
1667
SmallVector<const SCEVPredicate *, 4 > Predicates;
1668
- std::optional<std::pair< BasicBlock *, BasicBlock *>> SingleUncountableEdge ;
1668
+ BasicBlock *SingleUncountableExitingBlock ;
1669
1669
for (BasicBlock *BB : ExitingBlocks) {
1670
1670
const SCEV *EC =
1671
1671
PSE.getSE ()->getPredicatedExitCount (TheLoop, BB, &Predicates);
@@ -1687,15 +1687,15 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
1687
1687
ExitBlock = Succs[1 ];
1688
1688
}
1689
1689
1690
- if (SingleUncountableEdge ) {
1690
+ if (SingleUncountableExitingBlock ) {
1691
1691
reportVectorizationFailure (
1692
1692
" Loop has too many uncountable exits" ,
1693
1693
" Cannot vectorize early exit loop with more than one early exit" ,
1694
1694
" TooManyUncountableEarlyExits" , ORE, TheLoop);
1695
1695
return false ;
1696
1696
}
1697
1697
1698
- SingleUncountableEdge = {BB, ExitBlock} ;
1698
+ SingleUncountableExitingBlock = BB ;
1699
1699
} else
1700
1700
CountableExitingBlocks.push_back (BB);
1701
1701
}
@@ -1705,15 +1705,15 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
1705
1705
// PSE.getSymbolicMaxBackedgeTakenCount() below.
1706
1706
Predicates.clear ();
1707
1707
1708
- if (!SingleUncountableEdge ) {
1708
+ if (!SingleUncountableExitingBlock ) {
1709
1709
LLVM_DEBUG (dbgs () << " LV: Cound not find any uncountable exits" );
1710
1710
return false ;
1711
1711
}
1712
1712
1713
1713
// The only supported early exit loops so far are ones where the early
1714
1714
// exiting block is a unique predecessor of the latch block.
1715
1715
BasicBlock *LatchPredBB = LatchBB->getUniquePredecessor ();
1716
- if (LatchPredBB != SingleUncountableEdge-> first ) {
1716
+ if (LatchPredBB != SingleUncountableExitingBlock ) {
1717
1717
reportVectorizationFailure (" Early exit is not the latch predecessor" ,
1718
1718
" Cannot vectorize early exit loop" ,
1719
1719
" EarlyExitNotLatchPredecessor" , ORE, TheLoop);
@@ -1766,7 +1766,7 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
1766
1766
}
1767
1767
1768
1768
// The vectoriser cannot handle loads that occur after the early exit block.
1769
- assert (LatchBB->getUniquePredecessor () == SingleUncountableEdge-> first &&
1769
+ assert (LatchBB->getUniquePredecessor () == SingleUncountableExitingBlock &&
1770
1770
" Expected latch predecessor to be the early exiting block" );
1771
1771
1772
1772
// TODO: Handle loops that may fault.
@@ -1789,7 +1789,7 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
1789
1789
LLVM_DEBUG (dbgs () << " LV: Found an early exit loop with symbolic max "
1790
1790
" backedge taken count: "
1791
1791
<< *SymbolicMaxBTC << ' \n ' );
1792
- UncountableEdge = SingleUncountableEdge ;
1792
+ UncountableExitingBB = SingleUncountableExitingBlock ;
1793
1793
return true ;
1794
1794
}
1795
1795
@@ -1861,7 +1861,8 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
1861
1861
return false ;
1862
1862
} else {
1863
1863
if (!isVectorizableEarlyExitLoop ()) {
1864
- UncountableEdge = std::nullopt;
1864
+ assert (!hasUncountableEarlyExit () &&
1865
+ " Must be false without vectorizable early-exit loop" );
1865
1866
if (DoExtraAnalysis)
1866
1867
Result = false ;
1867
1868
else
0 commit comments