@@ -9058,7 +9058,7 @@ addUsersInExitBlocks(VPlan &Plan,
90589058 // Introduce extract for exiting values and update the VPIRInstructions
90599059 // modeling the corresponding LCSSA phis.
90609060 for (VPIRInstruction *ExitIRI : ExitUsersToFix) {
9061- for (VPValue *Op : ExitIRI->operands ()) {
9061+ for (const auto &[Idx, Op] : enumerate( ExitIRI->operands () )) {
90629062 // Pass live-in values used by exit phis directly through to their users
90639063 // in the exit block.
90649064 if (Op->isLiveIn ())
@@ -9073,7 +9073,7 @@ addUsersInExitBlocks(VPlan &Plan,
90739073 VPValue *Ext = B.createNaryOp (VPInstruction::ExtractFromEnd,
90749074 {Op, Plan.getOrAddLiveIn (ConstantInt::get (
90759075 IntegerType::get (Ctx, 32 ), 1 ))});
9076- ExitIRI->setOperand (0 , Ext);
9076+ ExitIRI->setOperand (Idx , Ext);
90779077 }
90789078 }
90799079 return true ;
@@ -10236,36 +10236,11 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1023610236 return false ;
1023710237 }
1023810238
10239- if (LVL.hasUncountableEarlyExit ()) {
10240- if (!EnableEarlyExitVectorization) {
10241- reportVectorizationFailure (" Auto-vectorization of loops with uncountable "
10242- " early exit is not enabled" ,
10243- " UncountableEarlyExitLoopsDisabled" , ORE, L);
10244- return false ;
10245- }
10246-
10247- // In addUsersInExitBlocks we already bail out if there is an outside use
10248- // of a loop-defined variable, but it ignores induction variables which are
10249- // handled by InnerLoopVectorizer::fixupIVUsers. We need to bail out if we
10250- // encounter induction variables too otherwise fixupIVUsers will crash.
10251- BasicBlock *LoopLatch = L->getLoopLatch ();
10252- for (const auto &Induction : LVL.getInductionVars ()) {
10253- PHINode *Ind = Induction.first ;
10254- Instruction *IndUpdate =
10255- cast<Instruction>(Ind->getIncomingValueForBlock (LoopLatch));
10256- for (Instruction *I : {cast<Instruction>(Ind), IndUpdate}) {
10257- for (User *U : I->users ()) {
10258- Instruction *UI = cast<Instruction>(U);
10259- if (!L->contains (UI)) {
10260- reportVectorizationFailure (
10261- " Auto-vectorization of loops with uncountable early exits and "
10262- " outside uses of induction variables unsupported" ,
10263- " UncountableEarlyExitLoopIndLiveOutsUnsupported" , ORE, L);
10264- return false ;
10265- }
10266- }
10267- }
10268- }
10239+ if (LVL.hasUncountableEarlyExit () && !EnableEarlyExitVectorization) {
10240+ reportVectorizationFailure (" Auto-vectorization of loops with uncountable "
10241+ " early exit is not enabled" ,
10242+ " UncountableEarlyExitLoopsDisabled" , ORE, L);
10243+ return false ;
1026910244 }
1027010245
1027110246 // Entrance to the VPlan-native vectorization path. Outer loops are processed
0 commit comments