1 //===- VPlan.cpp - Vectorizer Plan ----------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// 9 /// \file 10 /// This is the LLVM vectorization plan. It represents a candidate for 11 /// vectorization, allowing to plan and optimize how to vectorize a given loop 12 /// before generating LLVM-IR. 13 /// The vectorizer uses vectorization plans to estimate the costs of potential 14 /// candidates and if profitable to execute the desired plan, generating vector 15 /// LLVM-IR code. 16 /// 17 //===----------------------------------------------------------------------===// 18 19 #include "VPlan.h" 20 #include "VPlanDominatorTree.h" 21 #include "llvm/ADT/DepthFirstIterator.h" 22 #include "llvm/ADT/PostOrderIterator.h" 23 #include "llvm/ADT/STLExtras.h" 24 #include "llvm/ADT/SmallVector.h" 25 #include "llvm/ADT/Twine.h" 26 #include "llvm/Analysis/IVDescriptors.h" 27 #include "llvm/Analysis/LoopInfo.h" 28 #include "llvm/IR/BasicBlock.h" 29 #include "llvm/IR/CFG.h" 30 #include "llvm/IR/InstrTypes.h" 31 #include "llvm/IR/Instruction.h" 32 #include "llvm/IR/Instructions.h" 33 #include "llvm/IR/Type.h" 34 #include "llvm/IR/Value.h" 35 #include "llvm/Support/Casting.h" 36 #include "llvm/Support/CommandLine.h" 37 #include "llvm/Support/Debug.h" 38 #include "llvm/Support/ErrorHandling.h" 39 #include "llvm/Support/GenericDomTreeConstruction.h" 40 #include "llvm/Support/GraphWriter.h" 41 #include "llvm/Support/raw_ostream.h" 42 #include "llvm/Transforms/Utils/BasicBlockUtils.h" 43 #include <cassert> 44 #include <iterator> 45 #include <string> 46 #include <vector> 47 48 using namespace llvm; 49 extern cl::opt<bool> EnableVPlanNativePath; 50 51 #define DEBUG_TYPE "vplan" 52 53 raw_ostream &llvm::operator<<(raw_ostream &OS, const VPValue &V) { 54 const VPInstruction *Instr = dyn_cast<VPInstruction>(&V); 55 VPSlotTracker SlotTracker( 56 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr); 57 V.print(OS, SlotTracker); 58 return OS; 59 } 60 61 VPValue::VPValue(const unsigned char SC, Value *UV, VPDef *Def) 62 : SubclassID(SC), UnderlyingVal(UV), Def(Def) { 63 if (Def) 64 Def->addDefinedValue(this); 65 } 66 67 VPValue::~VPValue() { 68 assert(Users.empty() && "trying to delete a VPValue with remaining users"); 69 if (Def) 70 Def->removeDefinedValue(this); 71 } 72 73 void VPValue::print(raw_ostream &OS, VPSlotTracker &SlotTracker) const { 74 if (const VPRecipeBase *R = dyn_cast_or_null<VPRecipeBase>(Def)) 75 R->print(OS, "", SlotTracker); 76 else 77 printAsOperand(OS, SlotTracker); 78 } 79 80 void VPValue::dump() const { 81 const VPRecipeBase *Instr = dyn_cast_or_null<VPRecipeBase>(this->Def); 82 VPSlotTracker SlotTracker( 83 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr); 84 print(dbgs(), SlotTracker); 85 dbgs() << "\n"; 86 } 87 88 void VPDef::dump() const { 89 const VPRecipeBase *Instr = dyn_cast_or_null<VPRecipeBase>(this); 90 VPSlotTracker SlotTracker( 91 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr); 92 print(dbgs(), "", SlotTracker); 93 dbgs() << "\n"; 94 } 95 96 // Get the top-most entry block of \p Start. This is the entry block of the 97 // containing VPlan. This function is templated to support both const and non-const blocks 98 template <typename T> static T *getPlanEntry(T *Start) { 99 T *Next = Start; 100 T *Current = Start; 101 while ((Next = Next->getParent())) 102 Current = Next; 103 104 SmallSetVector<T *, 8> WorkList; 105 WorkList.insert(Current); 106 107 for (unsigned i = 0; i < WorkList.size(); i++) { 108 T *Current = WorkList[i]; 109 if (Current->getNumPredecessors() == 0) 110 return Current; 111 auto &Predecessors = Current->getPredecessors(); 112 WorkList.insert(Predecessors.begin(), Predecessors.end()); 113 } 114 115 llvm_unreachable("VPlan without any entry node without predecessors"); 116 } 117 118 VPlan *VPBlockBase::getPlan() { return getPlanEntry(this)->Plan; } 119 120 const VPlan *VPBlockBase::getPlan() const { return getPlanEntry(this)->Plan; } 121 122 /// \return the VPBasicBlock that is the entry of Block, possibly indirectly. 123 const VPBasicBlock *VPBlockBase::getEntryBasicBlock() const { 124 const VPBlockBase *Block = this; 125 while (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 126 Block = Region->getEntry(); 127 return cast<VPBasicBlock>(Block); 128 } 129 130 VPBasicBlock *VPBlockBase::getEntryBasicBlock() { 131 VPBlockBase *Block = this; 132 while (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 133 Block = Region->getEntry(); 134 return cast<VPBasicBlock>(Block); 135 } 136 137 void VPBlockBase::setPlan(VPlan *ParentPlan) { 138 assert(ParentPlan->getEntry() == this && 139 "Can only set plan on its entry block."); 140 Plan = ParentPlan; 141 } 142 143 /// \return the VPBasicBlock that is the exit of Block, possibly indirectly. 144 const VPBasicBlock *VPBlockBase::getExitBasicBlock() const { 145 const VPBlockBase *Block = this; 146 while (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 147 Block = Region->getExit(); 148 return cast<VPBasicBlock>(Block); 149 } 150 151 VPBasicBlock *VPBlockBase::getExitBasicBlock() { 152 VPBlockBase *Block = this; 153 while (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 154 Block = Region->getExit(); 155 return cast<VPBasicBlock>(Block); 156 } 157 158 VPBlockBase *VPBlockBase::getEnclosingBlockWithSuccessors() { 159 if (!Successors.empty() || !Parent) 160 return this; 161 assert(Parent->getExit() == this && 162 "Block w/o successors not the exit of its parent."); 163 return Parent->getEnclosingBlockWithSuccessors(); 164 } 165 166 VPBlockBase *VPBlockBase::getEnclosingBlockWithPredecessors() { 167 if (!Predecessors.empty() || !Parent) 168 return this; 169 assert(Parent->getEntry() == this && 170 "Block w/o predecessors not the entry of its parent."); 171 return Parent->getEnclosingBlockWithPredecessors(); 172 } 173 174 void VPBlockBase::deleteCFG(VPBlockBase *Entry) { 175 SmallVector<VPBlockBase *, 8> Blocks(depth_first(Entry)); 176 177 for (VPBlockBase *Block : Blocks) 178 delete Block; 179 } 180 181 VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() { 182 iterator It = begin(); 183 while (It != end() && (isa<VPWidenPHIRecipe>(&*It) || 184 isa<VPWidenIntOrFpInductionRecipe>(&*It) || 185 isa<VPPredInstPHIRecipe>(&*It) || 186 isa<VPWidenCanonicalIVRecipe>(&*It))) 187 It++; 188 return It; 189 } 190 191 Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) { 192 if (!Def->getDef()) 193 return Def->getLiveInIRValue(); 194 195 if (hasScalarValue(Def, Instance)) 196 return Data.PerPartScalars[Def][Instance.Part][Instance.Lane]; 197 198 assert(hasVectorValue(Def, Instance.Part)); 199 auto *VecPart = Data.PerPartOutput[Def][Instance.Part]; 200 if (!VecPart->getType()->isVectorTy()) { 201 assert(Instance.Lane == 0 && "cannot get lane > 0 for scalar"); 202 return VecPart; 203 } 204 // TODO: Cache created scalar values. 205 auto *Extract = 206 Builder.CreateExtractElement(VecPart, Builder.getInt32(Instance.Lane)); 207 // set(Def, Extract, Instance); 208 return Extract; 209 } 210 211 BasicBlock * 212 VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) { 213 // BB stands for IR BasicBlocks. VPBB stands for VPlan VPBasicBlocks. 214 // Pred stands for Predessor. Prev stands for Previous - last visited/created. 215 BasicBlock *PrevBB = CFG.PrevBB; 216 BasicBlock *NewBB = BasicBlock::Create(PrevBB->getContext(), getName(), 217 PrevBB->getParent(), CFG.LastBB); 218 LLVM_DEBUG(dbgs() << "LV: created " << NewBB->getName() << '\n'); 219 220 // Hook up the new basic block to its predecessors. 221 for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) { 222 VPBasicBlock *PredVPBB = PredVPBlock->getExitBasicBlock(); 223 auto &PredVPSuccessors = PredVPBB->getSuccessors(); 224 BasicBlock *PredBB = CFG.VPBB2IRBB[PredVPBB]; 225 226 // In outer loop vectorization scenario, the predecessor BBlock may not yet 227 // be visited(backedge). Mark the VPBasicBlock for fixup at the end of 228 // vectorization. We do not encounter this case in inner loop vectorization 229 // as we start out by building a loop skeleton with the vector loop header 230 // and latch blocks. As a result, we never enter this function for the 231 // header block in the non VPlan-native path. 232 if (!PredBB) { 233 assert(EnableVPlanNativePath && 234 "Unexpected null predecessor in non VPlan-native path"); 235 CFG.VPBBsToFix.push_back(PredVPBB); 236 continue; 237 } 238 239 assert(PredBB && "Predecessor basic-block not found building successor."); 240 auto *PredBBTerminator = PredBB->getTerminator(); 241 LLVM_DEBUG(dbgs() << "LV: draw edge from" << PredBB->getName() << '\n'); 242 if (isa<UnreachableInst>(PredBBTerminator)) { 243 assert(PredVPSuccessors.size() == 1 && 244 "Predecessor ending w/o branch must have single successor."); 245 PredBBTerminator->eraseFromParent(); 246 BranchInst::Create(NewBB, PredBB); 247 } else { 248 assert(PredVPSuccessors.size() == 2 && 249 "Predecessor ending with branch must have two successors."); 250 unsigned idx = PredVPSuccessors.front() == this ? 0 : 1; 251 assert(!PredBBTerminator->getSuccessor(idx) && 252 "Trying to reset an existing successor block."); 253 PredBBTerminator->setSuccessor(idx, NewBB); 254 } 255 } 256 return NewBB; 257 } 258 259 void VPBasicBlock::execute(VPTransformState *State) { 260 bool Replica = State->Instance && !State->Instance->isFirstIteration(); 261 VPBasicBlock *PrevVPBB = State->CFG.PrevVPBB; 262 VPBlockBase *SingleHPred = nullptr; 263 BasicBlock *NewBB = State->CFG.PrevBB; // Reuse it if possible. 264 265 // 1. Create an IR basic block, or reuse the last one if possible. 266 // The last IR basic block is reused, as an optimization, in three cases: 267 // A. the first VPBB reuses the loop header BB - when PrevVPBB is null; 268 // B. when the current VPBB has a single (hierarchical) predecessor which 269 // is PrevVPBB and the latter has a single (hierarchical) successor; and 270 // C. when the current VPBB is an entry of a region replica - where PrevVPBB 271 // is the exit of this region from a previous instance, or the predecessor 272 // of this region. 273 if (PrevVPBB && /* A */ 274 !((SingleHPred = getSingleHierarchicalPredecessor()) && 275 SingleHPred->getExitBasicBlock() == PrevVPBB && 276 PrevVPBB->getSingleHierarchicalSuccessor()) && /* B */ 277 !(Replica && getPredecessors().empty())) { /* C */ 278 NewBB = createEmptyBasicBlock(State->CFG); 279 State->Builder.SetInsertPoint(NewBB); 280 // Temporarily terminate with unreachable until CFG is rewired. 281 UnreachableInst *Terminator = State->Builder.CreateUnreachable(); 282 State->Builder.SetInsertPoint(Terminator); 283 // Register NewBB in its loop. In innermost loops its the same for all BB's. 284 Loop *L = State->LI->getLoopFor(State->CFG.LastBB); 285 L->addBasicBlockToLoop(NewBB, *State->LI); 286 State->CFG.PrevBB = NewBB; 287 } 288 289 // 2. Fill the IR basic block with IR instructions. 290 LLVM_DEBUG(dbgs() << "LV: vectorizing VPBB:" << getName() 291 << " in BB:" << NewBB->getName() << '\n'); 292 293 State->CFG.VPBB2IRBB[this] = NewBB; 294 State->CFG.PrevVPBB = this; 295 296 for (VPRecipeBase &Recipe : Recipes) 297 Recipe.execute(*State); 298 299 VPValue *CBV; 300 if (EnableVPlanNativePath && (CBV = getCondBit())) { 301 Value *IRCBV = CBV->getUnderlyingValue(); 302 assert(IRCBV && "Unexpected null underlying value for condition bit"); 303 304 // Condition bit value in a VPBasicBlock is used as the branch selector. In 305 // the VPlan-native path case, since all branches are uniform we generate a 306 // branch instruction using the condition value from vector lane 0 and dummy 307 // successors. The successors are fixed later when the successor blocks are 308 // visited. 309 Value *NewCond = State->Callback.getOrCreateVectorValues(IRCBV, 0); 310 NewCond = State->Builder.CreateExtractElement(NewCond, 311 State->Builder.getInt32(0)); 312 313 // Replace the temporary unreachable terminator with the new conditional 314 // branch. 315 auto *CurrentTerminator = NewBB->getTerminator(); 316 assert(isa<UnreachableInst>(CurrentTerminator) && 317 "Expected to replace unreachable terminator with conditional " 318 "branch."); 319 auto *CondBr = BranchInst::Create(NewBB, nullptr, NewCond); 320 CondBr->setSuccessor(0, nullptr); 321 ReplaceInstWithInst(CurrentTerminator, CondBr); 322 } 323 324 LLVM_DEBUG(dbgs() << "LV: filled BB:" << *NewBB); 325 } 326 327 void VPBasicBlock::dropAllReferences(VPValue *NewValue) { 328 for (VPRecipeBase &R : Recipes) { 329 for (auto *Def : R.definedValues()) 330 Def->replaceAllUsesWith(NewValue); 331 332 for (unsigned I = 0, E = R.getNumOperands(); I != E; I++) 333 R.setOperand(I, NewValue); 334 } 335 } 336 337 void VPRegionBlock::dropAllReferences(VPValue *NewValue) { 338 for (VPBlockBase *Block : depth_first(Entry)) 339 // Drop all references in VPBasicBlocks and replace all uses with 340 // DummyValue. 341 Block->dropAllReferences(NewValue); 342 } 343 344 void VPRegionBlock::execute(VPTransformState *State) { 345 ReversePostOrderTraversal<VPBlockBase *> RPOT(Entry); 346 347 if (!isReplicator()) { 348 // Visit the VPBlocks connected to "this", starting from it. 349 for (VPBlockBase *Block : RPOT) { 350 if (EnableVPlanNativePath) { 351 // The inner loop vectorization path does not represent loop preheader 352 // and exit blocks as part of the VPlan. In the VPlan-native path, skip 353 // vectorizing loop preheader block. In future, we may replace this 354 // check with the check for loop preheader. 355 if (Block->getNumPredecessors() == 0) 356 continue; 357 358 // Skip vectorizing loop exit block. In future, we may replace this 359 // check with the check for loop exit. 360 if (Block->getNumSuccessors() == 0) 361 continue; 362 } 363 364 LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); 365 Block->execute(State); 366 } 367 return; 368 } 369 370 assert(!State->Instance && "Replicating a Region with non-null instance."); 371 372 // Enter replicating mode. 373 State->Instance = VPIteration(0, 0); 374 375 for (unsigned Part = 0, UF = State->UF; Part < UF; ++Part) { 376 State->Instance->Part = Part; 377 assert(!State->VF.isScalable() && "VF is assumed to be non scalable."); 378 for (unsigned Lane = 0, VF = State->VF.getKnownMinValue(); Lane < VF; 379 ++Lane) { 380 State->Instance->Lane = Lane; 381 // Visit the VPBlocks connected to \p this, starting from it. 382 for (VPBlockBase *Block : RPOT) { 383 LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n'); 384 Block->execute(State); 385 } 386 } 387 } 388 389 // Exit replicating mode. 390 State->Instance.reset(); 391 } 392 393 void VPRecipeBase::insertBefore(VPRecipeBase *InsertPos) { 394 assert(!Parent && "Recipe already in some VPBasicBlock"); 395 assert(InsertPos->getParent() && 396 "Insertion position not in any VPBasicBlock"); 397 Parent = InsertPos->getParent(); 398 Parent->getRecipeList().insert(InsertPos->getIterator(), this); 399 } 400 401 void VPRecipeBase::insertAfter(VPRecipeBase *InsertPos) { 402 assert(!Parent && "Recipe already in some VPBasicBlock"); 403 assert(InsertPos->getParent() && 404 "Insertion position not in any VPBasicBlock"); 405 Parent = InsertPos->getParent(); 406 Parent->getRecipeList().insertAfter(InsertPos->getIterator(), this); 407 } 408 409 void VPRecipeBase::removeFromParent() { 410 assert(getParent() && "Recipe not in any VPBasicBlock"); 411 getParent()->getRecipeList().remove(getIterator()); 412 Parent = nullptr; 413 } 414 415 iplist<VPRecipeBase>::iterator VPRecipeBase::eraseFromParent() { 416 assert(getParent() && "Recipe not in any VPBasicBlock"); 417 return getParent()->getRecipeList().erase(getIterator()); 418 } 419 420 void VPRecipeBase::moveAfter(VPRecipeBase *InsertPos) { 421 removeFromParent(); 422 insertAfter(InsertPos); 423 } 424 425 void VPRecipeBase::moveBefore(VPBasicBlock &BB, 426 iplist<VPRecipeBase>::iterator I) { 427 assert(I == BB.end() || I->getParent() == &BB); 428 removeFromParent(); 429 Parent = &BB; 430 BB.getRecipeList().insert(I, this); 431 } 432 433 void VPInstruction::generateInstruction(VPTransformState &State, 434 unsigned Part) { 435 IRBuilder<> &Builder = State.Builder; 436 437 if (Instruction::isBinaryOp(getOpcode())) { 438 Value *A = State.get(getOperand(0), Part); 439 Value *B = State.get(getOperand(1), Part); 440 Value *V = Builder.CreateBinOp((Instruction::BinaryOps)getOpcode(), A, B); 441 State.set(this, V, Part); 442 return; 443 } 444 445 switch (getOpcode()) { 446 case VPInstruction::Not: { 447 Value *A = State.get(getOperand(0), Part); 448 Value *V = Builder.CreateNot(A); 449 State.set(this, V, Part); 450 break; 451 } 452 case VPInstruction::ICmpULE: { 453 Value *IV = State.get(getOperand(0), Part); 454 Value *TC = State.get(getOperand(1), Part); 455 Value *V = Builder.CreateICmpULE(IV, TC); 456 State.set(this, V, Part); 457 break; 458 } 459 case Instruction::Select: { 460 Value *Cond = State.get(getOperand(0), Part); 461 Value *Op1 = State.get(getOperand(1), Part); 462 Value *Op2 = State.get(getOperand(2), Part); 463 Value *V = Builder.CreateSelect(Cond, Op1, Op2); 464 State.set(this, V, Part); 465 break; 466 } 467 case VPInstruction::ActiveLaneMask: { 468 // Get first lane of vector induction variable. 469 Value *VIVElem0 = State.get(getOperand(0), VPIteration(Part, 0)); 470 // Get the original loop tripcount. 471 Value *ScalarTC = State.TripCount; 472 473 auto *Int1Ty = Type::getInt1Ty(Builder.getContext()); 474 auto *PredTy = FixedVectorType::get(Int1Ty, State.VF.getKnownMinValue()); 475 Instruction *Call = Builder.CreateIntrinsic( 476 Intrinsic::get_active_lane_mask, {PredTy, ScalarTC->getType()}, 477 {VIVElem0, ScalarTC}, nullptr, "active.lane.mask"); 478 State.set(this, Call, Part); 479 break; 480 } 481 default: 482 llvm_unreachable("Unsupported opcode for instruction"); 483 } 484 } 485 486 void VPInstruction::execute(VPTransformState &State) { 487 assert(!State.Instance && "VPInstruction executing an Instance"); 488 for (unsigned Part = 0; Part < State.UF; ++Part) 489 generateInstruction(State, Part); 490 } 491 492 void VPInstruction::dump() const { 493 VPSlotTracker SlotTracker(getParent()->getPlan()); 494 print(dbgs(), "", SlotTracker); 495 } 496 497 void VPInstruction::print(raw_ostream &O, const Twine &Indent, 498 VPSlotTracker &SlotTracker) const { 499 O << "EMIT "; 500 501 if (hasResult()) { 502 printAsOperand(O, SlotTracker); 503 O << " = "; 504 } 505 506 switch (getOpcode()) { 507 case VPInstruction::Not: 508 O << "not"; 509 break; 510 case VPInstruction::ICmpULE: 511 O << "icmp ule"; 512 break; 513 case VPInstruction::SLPLoad: 514 O << "combined load"; 515 break; 516 case VPInstruction::SLPStore: 517 O << "combined store"; 518 break; 519 case VPInstruction::ActiveLaneMask: 520 O << "active lane mask"; 521 break; 522 523 default: 524 O << Instruction::getOpcodeName(getOpcode()); 525 } 526 527 for (const VPValue *Operand : operands()) { 528 O << " "; 529 Operand->printAsOperand(O, SlotTracker); 530 } 531 } 532 533 /// Generate the code inside the body of the vectorized loop. Assumes a single 534 /// LoopVectorBody basic-block was created for this. Introduce additional 535 /// basic-blocks as needed, and fill them all. 536 void VPlan::execute(VPTransformState *State) { 537 // -1. Check if the backedge taken count is needed, and if so build it. 538 if (BackedgeTakenCount && BackedgeTakenCount->getNumUsers()) { 539 Value *TC = State->TripCount; 540 IRBuilder<> Builder(State->CFG.PrevBB->getTerminator()); 541 auto *TCMO = Builder.CreateSub(TC, ConstantInt::get(TC->getType(), 1), 542 "trip.count.minus.1"); 543 auto VF = State->VF; 544 Value *VTCMO = 545 VF.isScalar() ? TCMO : Builder.CreateVectorSplat(VF, TCMO, "broadcast"); 546 for (unsigned Part = 0, UF = State->UF; Part < UF; ++Part) 547 State->set(BackedgeTakenCount, VTCMO, Part); 548 } 549 550 // 0. Set the reverse mapping from VPValues to Values for code generation. 551 for (auto &Entry : Value2VPValue) 552 State->VPValue2Value[Entry.second] = Entry.first; 553 554 BasicBlock *VectorPreHeaderBB = State->CFG.PrevBB; 555 BasicBlock *VectorHeaderBB = VectorPreHeaderBB->getSingleSuccessor(); 556 assert(VectorHeaderBB && "Loop preheader does not have a single successor."); 557 558 // 1. Make room to generate basic-blocks inside loop body if needed. 559 BasicBlock *VectorLatchBB = VectorHeaderBB->splitBasicBlock( 560 VectorHeaderBB->getFirstInsertionPt(), "vector.body.latch"); 561 Loop *L = State->LI->getLoopFor(VectorHeaderBB); 562 L->addBasicBlockToLoop(VectorLatchBB, *State->LI); 563 // Remove the edge between Header and Latch to allow other connections. 564 // Temporarily terminate with unreachable until CFG is rewired. 565 // Note: this asserts the generated code's assumption that 566 // getFirstInsertionPt() can be dereferenced into an Instruction. 567 VectorHeaderBB->getTerminator()->eraseFromParent(); 568 State->Builder.SetInsertPoint(VectorHeaderBB); 569 UnreachableInst *Terminator = State->Builder.CreateUnreachable(); 570 State->Builder.SetInsertPoint(Terminator); 571 572 // 2. Generate code in loop body. 573 State->CFG.PrevVPBB = nullptr; 574 State->CFG.PrevBB = VectorHeaderBB; 575 State->CFG.LastBB = VectorLatchBB; 576 577 for (VPBlockBase *Block : depth_first(Entry)) 578 Block->execute(State); 579 580 // Setup branch terminator successors for VPBBs in VPBBsToFix based on 581 // VPBB's successors. 582 for (auto VPBB : State->CFG.VPBBsToFix) { 583 assert(EnableVPlanNativePath && 584 "Unexpected VPBBsToFix in non VPlan-native path"); 585 BasicBlock *BB = State->CFG.VPBB2IRBB[VPBB]; 586 assert(BB && "Unexpected null basic block for VPBB"); 587 588 unsigned Idx = 0; 589 auto *BBTerminator = BB->getTerminator(); 590 591 for (VPBlockBase *SuccVPBlock : VPBB->getHierarchicalSuccessors()) { 592 VPBasicBlock *SuccVPBB = SuccVPBlock->getEntryBasicBlock(); 593 BBTerminator->setSuccessor(Idx, State->CFG.VPBB2IRBB[SuccVPBB]); 594 ++Idx; 595 } 596 } 597 598 // 3. Merge the temporary latch created with the last basic-block filled. 599 BasicBlock *LastBB = State->CFG.PrevBB; 600 // Connect LastBB to VectorLatchBB to facilitate their merge. 601 assert((EnableVPlanNativePath || 602 isa<UnreachableInst>(LastBB->getTerminator())) && 603 "Expected InnerLoop VPlan CFG to terminate with unreachable"); 604 assert((!EnableVPlanNativePath || isa<BranchInst>(LastBB->getTerminator())) && 605 "Expected VPlan CFG to terminate with branch in NativePath"); 606 LastBB->getTerminator()->eraseFromParent(); 607 BranchInst::Create(VectorLatchBB, LastBB); 608 609 // Merge LastBB with Latch. 610 bool Merged = MergeBlockIntoPredecessor(VectorLatchBB, nullptr, State->LI); 611 (void)Merged; 612 assert(Merged && "Could not merge last basic block with latch."); 613 VectorLatchBB = LastBB; 614 615 // We do not attempt to preserve DT for outer loop vectorization currently. 616 if (!EnableVPlanNativePath) 617 updateDominatorTree(State->DT, VectorPreHeaderBB, VectorLatchBB, 618 L->getExitBlock()); 619 } 620 621 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 622 LLVM_DUMP_METHOD 623 void VPlan::dump() const { dbgs() << *this << '\n'; } 624 #endif 625 626 void VPlan::updateDominatorTree(DominatorTree *DT, BasicBlock *LoopPreHeaderBB, 627 BasicBlock *LoopLatchBB, 628 BasicBlock *LoopExitBB) { 629 BasicBlock *LoopHeaderBB = LoopPreHeaderBB->getSingleSuccessor(); 630 assert(LoopHeaderBB && "Loop preheader does not have a single successor."); 631 // The vector body may be more than a single basic-block by this point. 632 // Update the dominator tree information inside the vector body by propagating 633 // it from header to latch, expecting only triangular control-flow, if any. 634 BasicBlock *PostDomSucc = nullptr; 635 for (auto *BB = LoopHeaderBB; BB != LoopLatchBB; BB = PostDomSucc) { 636 // Get the list of successors of this block. 637 std::vector<BasicBlock *> Succs(succ_begin(BB), succ_end(BB)); 638 assert(Succs.size() <= 2 && 639 "Basic block in vector loop has more than 2 successors."); 640 PostDomSucc = Succs[0]; 641 if (Succs.size() == 1) { 642 assert(PostDomSucc->getSinglePredecessor() && 643 "PostDom successor has more than one predecessor."); 644 DT->addNewBlock(PostDomSucc, BB); 645 continue; 646 } 647 BasicBlock *InterimSucc = Succs[1]; 648 if (PostDomSucc->getSingleSuccessor() == InterimSucc) { 649 PostDomSucc = Succs[1]; 650 InterimSucc = Succs[0]; 651 } 652 assert(InterimSucc->getSingleSuccessor() == PostDomSucc && 653 "One successor of a basic block does not lead to the other."); 654 assert(InterimSucc->getSinglePredecessor() && 655 "Interim successor has more than one predecessor."); 656 assert(PostDomSucc->hasNPredecessors(2) && 657 "PostDom successor has more than two predecessors."); 658 DT->addNewBlock(InterimSucc, BB); 659 DT->addNewBlock(PostDomSucc, BB); 660 } 661 // Latch block is a new dominator for the loop exit. 662 DT->changeImmediateDominator(LoopExitBB, LoopLatchBB); 663 assert(DT->verify(DominatorTree::VerificationLevel::Fast)); 664 } 665 666 const Twine VPlanPrinter::getUID(const VPBlockBase *Block) { 667 return (isa<VPRegionBlock>(Block) ? "cluster_N" : "N") + 668 Twine(getOrCreateBID(Block)); 669 } 670 671 const Twine VPlanPrinter::getOrCreateName(const VPBlockBase *Block) { 672 const std::string &Name = Block->getName(); 673 if (!Name.empty()) 674 return Name; 675 return "VPB" + Twine(getOrCreateBID(Block)); 676 } 677 678 void VPlanPrinter::dump() { 679 Depth = 1; 680 bumpIndent(0); 681 OS << "digraph VPlan {\n"; 682 OS << "graph [labelloc=t, fontsize=30; label=\"Vectorization Plan"; 683 if (!Plan.getName().empty()) 684 OS << "\\n" << DOT::EscapeString(Plan.getName()); 685 if (Plan.BackedgeTakenCount) { 686 OS << ", where:\\n"; 687 Plan.BackedgeTakenCount->print(OS, SlotTracker); 688 OS << " := BackedgeTakenCount"; 689 } 690 OS << "\"]\n"; 691 OS << "node [shape=rect, fontname=Courier, fontsize=30]\n"; 692 OS << "edge [fontname=Courier, fontsize=30]\n"; 693 OS << "compound=true\n"; 694 695 for (const VPBlockBase *Block : depth_first(Plan.getEntry())) 696 dumpBlock(Block); 697 698 OS << "}\n"; 699 } 700 701 void VPlanPrinter::dumpBlock(const VPBlockBase *Block) { 702 if (const VPBasicBlock *BasicBlock = dyn_cast<VPBasicBlock>(Block)) 703 dumpBasicBlock(BasicBlock); 704 else if (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 705 dumpRegion(Region); 706 else 707 llvm_unreachable("Unsupported kind of VPBlock."); 708 } 709 710 void VPlanPrinter::drawEdge(const VPBlockBase *From, const VPBlockBase *To, 711 bool Hidden, const Twine &Label) { 712 // Due to "dot" we print an edge between two regions as an edge between the 713 // exit basic block and the entry basic of the respective regions. 714 const VPBlockBase *Tail = From->getExitBasicBlock(); 715 const VPBlockBase *Head = To->getEntryBasicBlock(); 716 OS << Indent << getUID(Tail) << " -> " << getUID(Head); 717 OS << " [ label=\"" << Label << '\"'; 718 if (Tail != From) 719 OS << " ltail=" << getUID(From); 720 if (Head != To) 721 OS << " lhead=" << getUID(To); 722 if (Hidden) 723 OS << "; splines=none"; 724 OS << "]\n"; 725 } 726 727 void VPlanPrinter::dumpEdges(const VPBlockBase *Block) { 728 auto &Successors = Block->getSuccessors(); 729 if (Successors.size() == 1) 730 drawEdge(Block, Successors.front(), false, ""); 731 else if (Successors.size() == 2) { 732 drawEdge(Block, Successors.front(), false, "T"); 733 drawEdge(Block, Successors.back(), false, "F"); 734 } else { 735 unsigned SuccessorNumber = 0; 736 for (auto *Successor : Successors) 737 drawEdge(Block, Successor, false, Twine(SuccessorNumber++)); 738 } 739 } 740 741 void VPlanPrinter::dumpBasicBlock(const VPBasicBlock *BasicBlock) { 742 OS << Indent << getUID(BasicBlock) << " [label =\n"; 743 bumpIndent(1); 744 OS << Indent << "\"" << DOT::EscapeString(BasicBlock->getName()) << ":\\n\""; 745 bumpIndent(1); 746 747 // Dump the block predicate. 748 const VPValue *Pred = BasicBlock->getPredicate(); 749 if (Pred) { 750 OS << " +\n" << Indent << " \"BlockPredicate: \""; 751 if (const VPInstruction *PredI = dyn_cast<VPInstruction>(Pred)) { 752 PredI->printAsOperand(OS, SlotTracker); 753 OS << " (" << DOT::EscapeString(PredI->getParent()->getName()) 754 << ")\\l\""; 755 } else 756 Pred->printAsOperand(OS, SlotTracker); 757 } 758 759 for (const VPRecipeBase &Recipe : *BasicBlock) { 760 OS << " +\n" << Indent << "\""; 761 Recipe.print(OS, Indent, SlotTracker); 762 OS << "\\l\""; 763 } 764 765 // Dump the condition bit. 766 const VPValue *CBV = BasicBlock->getCondBit(); 767 if (CBV) { 768 OS << " +\n" << Indent << " \"CondBit: "; 769 if (const VPInstruction *CBI = dyn_cast<VPInstruction>(CBV)) { 770 CBI->printAsOperand(OS, SlotTracker); 771 OS << " (" << DOT::EscapeString(CBI->getParent()->getName()) << ")\\l\""; 772 } else { 773 CBV->printAsOperand(OS, SlotTracker); 774 OS << "\""; 775 } 776 } 777 778 bumpIndent(-2); 779 OS << "\n" << Indent << "]\n"; 780 dumpEdges(BasicBlock); 781 } 782 783 void VPlanPrinter::dumpRegion(const VPRegionBlock *Region) { 784 OS << Indent << "subgraph " << getUID(Region) << " {\n"; 785 bumpIndent(1); 786 OS << Indent << "fontname=Courier\n" 787 << Indent << "label=\"" 788 << DOT::EscapeString(Region->isReplicator() ? "<xVFxUF> " : "<x1> ") 789 << DOT::EscapeString(Region->getName()) << "\"\n"; 790 // Dump the blocks of the region. 791 assert(Region->getEntry() && "Region contains no inner blocks."); 792 for (const VPBlockBase *Block : depth_first(Region->getEntry())) 793 dumpBlock(Block); 794 bumpIndent(-1); 795 OS << Indent << "}\n"; 796 dumpEdges(Region); 797 } 798 799 void VPlanPrinter::printAsIngredient(raw_ostream &O, const Value *V) { 800 std::string IngredientString; 801 raw_string_ostream RSO(IngredientString); 802 if (auto *Inst = dyn_cast<Instruction>(V)) { 803 if (!Inst->getType()->isVoidTy()) { 804 Inst->printAsOperand(RSO, false); 805 RSO << " = "; 806 } 807 RSO << Inst->getOpcodeName() << " "; 808 unsigned E = Inst->getNumOperands(); 809 if (E > 0) { 810 Inst->getOperand(0)->printAsOperand(RSO, false); 811 for (unsigned I = 1; I < E; ++I) 812 Inst->getOperand(I)->printAsOperand(RSO << ", ", false); 813 } 814 } else // !Inst 815 V->printAsOperand(RSO, false); 816 RSO.flush(); 817 O << DOT::EscapeString(IngredientString); 818 } 819 820 void VPWidenCallRecipe::print(raw_ostream &O, const Twine &Indent, 821 VPSlotTracker &SlotTracker) const { 822 O << "WIDEN-CALL "; 823 824 auto *CI = cast<CallInst>(getUnderlyingInstr()); 825 if (CI->getType()->isVoidTy()) 826 O << "void "; 827 else { 828 printAsOperand(O, SlotTracker); 829 O << " = "; 830 } 831 832 O << "call @" << CI->getCalledFunction()->getName() << "("; 833 printOperands(O, SlotTracker); 834 O << ")"; 835 } 836 837 void VPWidenSelectRecipe::print(raw_ostream &O, const Twine &Indent, 838 VPSlotTracker &SlotTracker) const { 839 O << "WIDEN-SELECT "; 840 printAsOperand(O, SlotTracker); 841 O << " = select "; 842 getOperand(0)->printAsOperand(O, SlotTracker); 843 O << ", "; 844 getOperand(1)->printAsOperand(O, SlotTracker); 845 O << ", "; 846 getOperand(2)->printAsOperand(O, SlotTracker); 847 O << (InvariantCond ? " (condition is loop invariant)" : ""); 848 } 849 850 void VPWidenRecipe::print(raw_ostream &O, const Twine &Indent, 851 VPSlotTracker &SlotTracker) const { 852 O << "WIDEN "; 853 printAsOperand(O, SlotTracker); 854 O << " = " << getUnderlyingInstr()->getOpcodeName() << " "; 855 printOperands(O, SlotTracker); 856 } 857 858 void VPWidenIntOrFpInductionRecipe::print(raw_ostream &O, const Twine &Indent, 859 VPSlotTracker &SlotTracker) const { 860 O << "WIDEN-INDUCTION"; 861 if (getTruncInst()) { 862 O << "\\l\""; 863 O << " +\n" << Indent << "\" " << VPlanIngredient(IV) << "\\l\""; 864 O << " +\n" << Indent << "\" "; 865 getVPValue(0)->printAsOperand(O, SlotTracker); 866 } else 867 O << " " << VPlanIngredient(IV); 868 } 869 870 void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent, 871 VPSlotTracker &SlotTracker) const { 872 O << "WIDEN-GEP "; 873 O << (IsPtrLoopInvariant ? "Inv" : "Var"); 874 size_t IndicesNumber = IsIndexLoopInvariant.size(); 875 for (size_t I = 0; I < IndicesNumber; ++I) 876 O << "[" << (IsIndexLoopInvariant[I] ? "Inv" : "Var") << "]"; 877 878 O << " "; 879 printAsOperand(O, SlotTracker); 880 O << " = getelementptr "; 881 printOperands(O, SlotTracker); 882 } 883 884 void VPWidenPHIRecipe::print(raw_ostream &O, const Twine &Indent, 885 VPSlotTracker &SlotTracker) const { 886 O << "WIDEN-PHI " << VPlanIngredient(getUnderlyingValue()); 887 } 888 889 void VPBlendRecipe::print(raw_ostream &O, const Twine &Indent, 890 VPSlotTracker &SlotTracker) const { 891 O << "BLEND "; 892 Phi->printAsOperand(O, false); 893 O << " ="; 894 if (getNumIncomingValues() == 1) { 895 // Not a User of any mask: not really blending, this is a 896 // single-predecessor phi. 897 O << " "; 898 getIncomingValue(0)->printAsOperand(O, SlotTracker); 899 } else { 900 for (unsigned I = 0, E = getNumIncomingValues(); I < E; ++I) { 901 O << " "; 902 getIncomingValue(I)->printAsOperand(O, SlotTracker); 903 O << "/"; 904 getMask(I)->printAsOperand(O, SlotTracker); 905 } 906 } 907 } 908 909 void VPReductionRecipe::print(raw_ostream &O, const Twine &Indent, 910 VPSlotTracker &SlotTracker) const { 911 O << "REDUCE "; 912 printAsOperand(O, SlotTracker); 913 O << " = "; 914 getChainOp()->printAsOperand(O, SlotTracker); 915 O << " + reduce." << Instruction::getOpcodeName(RdxDesc->getOpcode()) 916 << " ("; 917 getVecOp()->printAsOperand(O, SlotTracker); 918 if (getCondOp()) { 919 O << ", "; 920 getCondOp()->printAsOperand(O, SlotTracker); 921 } 922 O << ")"; 923 } 924 925 void VPReplicateRecipe::print(raw_ostream &O, const Twine &Indent, 926 VPSlotTracker &SlotTracker) const { 927 O << (IsUniform ? "CLONE " : "REPLICATE "); 928 929 if (!getUnderlyingInstr()->getType()->isVoidTy()) { 930 printAsOperand(O, SlotTracker); 931 O << " = "; 932 } 933 O << Instruction::getOpcodeName(getUnderlyingInstr()->getOpcode()) << " "; 934 printOperands(O, SlotTracker); 935 936 if (AlsoPack) 937 O << " (S->V)"; 938 } 939 940 void VPPredInstPHIRecipe::print(raw_ostream &O, const Twine &Indent, 941 VPSlotTracker &SlotTracker) const { 942 O << "PHI-PREDICATED-INSTRUCTION "; 943 printAsOperand(O, SlotTracker); 944 O << " = "; 945 printOperands(O, SlotTracker); 946 } 947 948 void VPWidenMemoryInstructionRecipe::print(raw_ostream &O, const Twine &Indent, 949 VPSlotTracker &SlotTracker) const { 950 O << "WIDEN "; 951 952 if (!isStore()) { 953 getVPValue()->printAsOperand(O, SlotTracker); 954 O << " = "; 955 } 956 O << Instruction::getOpcodeName(Ingredient.getOpcode()) << " "; 957 958 printOperands(O, SlotTracker); 959 } 960 961 void VPWidenCanonicalIVRecipe::execute(VPTransformState &State) { 962 Value *CanonicalIV = State.CanonicalIV; 963 Type *STy = CanonicalIV->getType(); 964 IRBuilder<> Builder(State.CFG.PrevBB->getTerminator()); 965 ElementCount VF = State.VF; 966 assert(!VF.isScalable() && "the code following assumes non scalables ECs"); 967 Value *VStart = VF.isScalar() 968 ? CanonicalIV 969 : Builder.CreateVectorSplat(VF.getKnownMinValue(), 970 CanonicalIV, "broadcast"); 971 for (unsigned Part = 0, UF = State.UF; Part < UF; ++Part) { 972 SmallVector<Constant *, 8> Indices; 973 for (unsigned Lane = 0; Lane < VF.getKnownMinValue(); ++Lane) 974 Indices.push_back( 975 ConstantInt::get(STy, Part * VF.getKnownMinValue() + Lane)); 976 // If VF == 1, there is only one iteration in the loop above, thus the 977 // element pushed back into Indices is ConstantInt::get(STy, Part) 978 Constant *VStep = 979 VF.isScalar() ? Indices.back() : ConstantVector::get(Indices); 980 // Add the consecutive indices to the vector value. 981 Value *CanonicalVectorIV = Builder.CreateAdd(VStart, VStep, "vec.iv"); 982 State.set(getVPValue(), CanonicalVectorIV, Part); 983 } 984 } 985 986 void VPWidenCanonicalIVRecipe::print(raw_ostream &O, const Twine &Indent, 987 VPSlotTracker &SlotTracker) const { 988 O << "EMIT "; 989 getVPValue()->printAsOperand(O, SlotTracker); 990 O << " = WIDEN-CANONICAL-INDUCTION"; 991 } 992 993 template void DomTreeBuilder::Calculate<VPDominatorTree>(VPDominatorTree &DT); 994 995 void VPValue::replaceAllUsesWith(VPValue *New) { 996 for (unsigned J = 0; J < getNumUsers();) { 997 VPUser *User = Users[J]; 998 unsigned NumUsers = getNumUsers(); 999 for (unsigned I = 0, E = User->getNumOperands(); I < E; ++I) 1000 if (User->getOperand(I) == this) 1001 User->setOperand(I, New); 1002 // If a user got removed after updating the current user, the next user to 1003 // update will be moved to the current position, so we only need to 1004 // increment the index if the number of users did not change. 1005 if (NumUsers == getNumUsers()) 1006 J++; 1007 } 1008 } 1009 1010 void VPValue::printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const { 1011 if (const Value *UV = getUnderlyingValue()) { 1012 OS << "ir<"; 1013 UV->printAsOperand(OS, false); 1014 OS << ">"; 1015 return; 1016 } 1017 1018 unsigned Slot = Tracker.getSlot(this); 1019 if (Slot == unsigned(-1)) 1020 OS << "<badref>"; 1021 else 1022 OS << "vp<%" << Tracker.getSlot(this) << ">"; 1023 } 1024 1025 void VPUser::printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const { 1026 interleaveComma(operands(), O, [&O, &SlotTracker](VPValue *Op) { 1027 Op->printAsOperand(O, SlotTracker); 1028 }); 1029 } 1030 1031 void VPInterleavedAccessInfo::visitRegion(VPRegionBlock *Region, 1032 Old2NewTy &Old2New, 1033 InterleavedAccessInfo &IAI) { 1034 ReversePostOrderTraversal<VPBlockBase *> RPOT(Region->getEntry()); 1035 for (VPBlockBase *Base : RPOT) { 1036 visitBlock(Base, Old2New, IAI); 1037 } 1038 } 1039 1040 void VPInterleavedAccessInfo::visitBlock(VPBlockBase *Block, Old2NewTy &Old2New, 1041 InterleavedAccessInfo &IAI) { 1042 if (VPBasicBlock *VPBB = dyn_cast<VPBasicBlock>(Block)) { 1043 for (VPRecipeBase &VPI : *VPBB) { 1044 assert(isa<VPInstruction>(&VPI) && "Can only handle VPInstructions"); 1045 auto *VPInst = cast<VPInstruction>(&VPI); 1046 auto *Inst = cast<Instruction>(VPInst->getUnderlyingValue()); 1047 auto *IG = IAI.getInterleaveGroup(Inst); 1048 if (!IG) 1049 continue; 1050 1051 auto NewIGIter = Old2New.find(IG); 1052 if (NewIGIter == Old2New.end()) 1053 Old2New[IG] = new InterleaveGroup<VPInstruction>( 1054 IG->getFactor(), IG->isReverse(), IG->getAlign()); 1055 1056 if (Inst == IG->getInsertPos()) 1057 Old2New[IG]->setInsertPos(VPInst); 1058 1059 InterleaveGroupMap[VPInst] = Old2New[IG]; 1060 InterleaveGroupMap[VPInst]->insertMember( 1061 VPInst, IG->getIndex(Inst), 1062 Align(IG->isReverse() ? (-1) * int(IG->getFactor()) 1063 : IG->getFactor())); 1064 } 1065 } else if (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block)) 1066 visitRegion(Region, Old2New, IAI); 1067 else 1068 llvm_unreachable("Unsupported kind of VPBlock."); 1069 } 1070 1071 VPInterleavedAccessInfo::VPInterleavedAccessInfo(VPlan &Plan, 1072 InterleavedAccessInfo &IAI) { 1073 Old2NewTy Old2New; 1074 visitRegion(cast<VPRegionBlock>(Plan.getEntry()), Old2New, IAI); 1075 } 1076 1077 void VPSlotTracker::assignSlot(const VPValue *V) { 1078 assert(Slots.find(V) == Slots.end() && "VPValue already has a slot!"); 1079 Slots[V] = NextSlot++; 1080 } 1081 1082 void VPSlotTracker::assignSlots(const VPBlockBase *VPBB) { 1083 if (auto *Region = dyn_cast<VPRegionBlock>(VPBB)) 1084 assignSlots(Region); 1085 else 1086 assignSlots(cast<VPBasicBlock>(VPBB)); 1087 } 1088 1089 void VPSlotTracker::assignSlots(const VPRegionBlock *Region) { 1090 ReversePostOrderTraversal<const VPBlockBase *> RPOT(Region->getEntry()); 1091 for (const VPBlockBase *Block : RPOT) 1092 assignSlots(Block); 1093 } 1094 1095 void VPSlotTracker::assignSlots(const VPBasicBlock *VPBB) { 1096 for (const VPRecipeBase &Recipe : *VPBB) { 1097 for (VPValue *Def : Recipe.definedValues()) 1098 assignSlot(Def); 1099 } 1100 } 1101 1102 void VPSlotTracker::assignSlots(const VPlan &Plan) { 1103 1104 for (const VPValue *V : Plan.VPExternalDefs) 1105 assignSlot(V); 1106 1107 if (Plan.BackedgeTakenCount) 1108 assignSlot(Plan.BackedgeTakenCount); 1109 1110 ReversePostOrderTraversal<const VPBlockBase *> RPOT(Plan.getEntry()); 1111 for (const VPBlockBase *Block : RPOT) 1112 assignSlots(Block); 1113 } 1114