LLVM 18.0.0git
VPlan.cpp
Go to the documentation of this file.
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 "VPlanCFG.h"
21#include "VPlanDominatorTree.h"
23#include "llvm/ADT/STLExtras.h"
26#include "llvm/ADT/Twine.h"
28#include "llvm/IR/BasicBlock.h"
29#include "llvm/IR/CFG.h"
30#include "llvm/IR/IRBuilder.h"
31#include "llvm/IR/Instruction.h"
33#include "llvm/IR/Type.h"
34#include "llvm/IR/Value.h"
37#include "llvm/Support/Debug.h"
44#include <cassert>
45#include <string>
46#include <vector>
47
48using namespace llvm;
49
50namespace llvm {
52}
53
54#define DEBUG_TYPE "vplan"
55
56#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
58 const VPInstruction *Instr = dyn_cast<VPInstruction>(&V);
60 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
61 V.print(OS, SlotTracker);
62 return OS;
63}
64#endif
65
67 const ElementCount &VF) const {
68 switch (LaneKind) {
70 // Lane = RuntimeVF - VF.getKnownMinValue() + Lane
71 return Builder.CreateSub(getRuntimeVF(Builder, Builder.getInt32Ty(), VF),
72 Builder.getInt32(VF.getKnownMinValue() - Lane));
74 return Builder.getInt32(Lane);
75 }
76 llvm_unreachable("Unknown lane kind");
77}
78
79VPValue::VPValue(const unsigned char SC, Value *UV, VPDef *Def)
80 : SubclassID(SC), UnderlyingVal(UV), Def(Def) {
81 if (Def)
82 Def->addDefinedValue(this);
83}
84
86 assert(Users.empty() && "trying to delete a VPValue with remaining users");
87 if (Def)
88 Def->removeDefinedValue(this);
89}
90
91#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
93 if (const VPRecipeBase *R = dyn_cast_or_null<VPRecipeBase>(Def))
94 R->print(OS, "", SlotTracker);
95 else
97}
98
99void VPValue::dump() const {
100 const VPRecipeBase *Instr = dyn_cast_or_null<VPRecipeBase>(this->Def);
102 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
104 dbgs() << "\n";
105}
106
107void VPDef::dump() const {
108 const VPRecipeBase *Instr = dyn_cast_or_null<VPRecipeBase>(this);
110 (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
111 print(dbgs(), "", SlotTracker);
112 dbgs() << "\n";
113}
114#endif
115
117 return cast_or_null<VPRecipeBase>(Def);
118}
119
121 return cast_or_null<VPRecipeBase>(Def);
122}
123
124// Get the top-most entry block of \p Start. This is the entry block of the
125// containing VPlan. This function is templated to support both const and non-const blocks
126template <typename T> static T *getPlanEntry(T *Start) {
127 T *Next = Start;
128 T *Current = Start;
129 while ((Next = Next->getParent()))
130 Current = Next;
131
132 SmallSetVector<T *, 8> WorkList;
133 WorkList.insert(Current);
134
135 for (unsigned i = 0; i < WorkList.size(); i++) {
136 T *Current = WorkList[i];
137 if (Current->getNumPredecessors() == 0)
138 return Current;
139 auto &Predecessors = Current->getPredecessors();
140 WorkList.insert(Predecessors.begin(), Predecessors.end());
141 }
142
143 llvm_unreachable("VPlan without any entry node without predecessors");
144}
145
146VPlan *VPBlockBase::getPlan() { return getPlanEntry(this)->Plan; }
147
148const VPlan *VPBlockBase::getPlan() const { return getPlanEntry(this)->Plan; }
149
150/// \return the VPBasicBlock that is the entry of Block, possibly indirectly.
152 const VPBlockBase *Block = this;
153 while (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
154 Block = Region->getEntry();
155 return cast<VPBasicBlock>(Block);
156}
157
159 VPBlockBase *Block = this;
160 while (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
161 Block = Region->getEntry();
162 return cast<VPBasicBlock>(Block);
163}
164
165void VPBlockBase::setPlan(VPlan *ParentPlan) {
166 assert(
167 (ParentPlan->getEntry() == this || ParentPlan->getPreheader() == this) &&
168 "Can only set plan on its entry or preheader block.");
169 Plan = ParentPlan;
170}
171
172/// \return the VPBasicBlock that is the exit of Block, possibly indirectly.
174 const VPBlockBase *Block = this;
175 while (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
176 Block = Region->getExiting();
177 return cast<VPBasicBlock>(Block);
178}
179
181 VPBlockBase *Block = this;
182 while (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
183 Block = Region->getExiting();
184 return cast<VPBasicBlock>(Block);
185}
186
188 if (!Successors.empty() || !Parent)
189 return this;
190 assert(Parent->getExiting() == this &&
191 "Block w/o successors not the exiting block of its parent.");
192 return Parent->getEnclosingBlockWithSuccessors();
193}
194
196 if (!Predecessors.empty() || !Parent)
197 return this;
198 assert(Parent->getEntry() == this &&
199 "Block w/o predecessors not the entry of its parent.");
200 return Parent->getEnclosingBlockWithPredecessors();
201}
202
205 delete Block;
206}
207
209 iterator It = begin();
210 while (It != end() && It->isPhi())
211 It++;
212 return It;
213}
214
216 if (Def->isLiveIn())
217 return Def->getLiveInIRValue();
218
219 if (hasScalarValue(Def, Instance)) {
220 return Data
221 .PerPartScalars[Def][Instance.Part][Instance.Lane.mapToCacheIndex(VF)];
222 }
223
224 assert(hasVectorValue(Def, Instance.Part));
225 auto *VecPart = Data.PerPartOutput[Def][Instance.Part];
226 if (!VecPart->getType()->isVectorTy()) {
227 assert(Instance.Lane.isFirstLane() && "cannot get lane > 0 for scalar");
228 return VecPart;
229 }
230 // TODO: Cache created scalar values.
231 Value *Lane = Instance.Lane.getAsRuntimeExpr(Builder, VF);
232 auto *Extract = Builder.CreateExtractElement(VecPart, Lane);
233 // set(Def, Extract, Instance);
234 return Extract;
235}
236
237Value *VPTransformState::get(VPValue *Def, unsigned Part) {
238 // If Values have been set for this Def return the one relevant for \p Part.
239 if (hasVectorValue(Def, Part))
240 return Data.PerPartOutput[Def][Part];
241
242 auto GetBroadcastInstrs = [this, Def](Value *V) {
243 bool SafeToHoist = Def->isDefinedOutsideVectorRegions();
244 if (VF.isScalar())
245 return V;
246 // Place the code for broadcasting invariant variables in the new preheader.
248 if (SafeToHoist) {
249 BasicBlock *LoopVectorPreHeader = CFG.VPBB2IRBB[cast<VPBasicBlock>(
251 if (LoopVectorPreHeader)
252 Builder.SetInsertPoint(LoopVectorPreHeader->getTerminator());
253 }
254
255 // Place the code for broadcasting invariant variables in the new preheader.
256 // Broadcast the scalar into all locations in the vector.
257 Value *Shuf = Builder.CreateVectorSplat(VF, V, "broadcast");
258
259 return Shuf;
260 };
261
262 if (!hasScalarValue(Def, {Part, 0})) {
263 assert(Def->isLiveIn() && "expected a live-in");
264 if (Part != 0)
265 return get(Def, 0);
266 Value *IRV = Def->getLiveInIRValue();
267 Value *B = GetBroadcastInstrs(IRV);
268 set(Def, B, Part);
269 return B;
270 }
271
272 Value *ScalarValue = get(Def, {Part, 0});
273 // If we aren't vectorizing, we can just copy the scalar map values over
274 // to the vector map.
275 if (VF.isScalar()) {
276 set(Def, ScalarValue, Part);
277 return ScalarValue;
278 }
279
280 bool IsUniform = vputils::isUniformAfterVectorization(Def);
281
282 unsigned LastLane = IsUniform ? 0 : VF.getKnownMinValue() - 1;
283 // Check if there is a scalar value for the selected lane.
284 if (!hasScalarValue(Def, {Part, LastLane})) {
285 // At the moment, VPWidenIntOrFpInductionRecipes, VPScalarIVStepsRecipes and
286 // VPExpandSCEVRecipes can also be uniform.
287 assert((isa<VPWidenIntOrFpInductionRecipe>(Def->getDefiningRecipe()) ||
288 isa<VPScalarIVStepsRecipe>(Def->getDefiningRecipe()) ||
289 isa<VPExpandSCEVRecipe>(Def->getDefiningRecipe())) &&
290 "unexpected recipe found to be invariant");
291 IsUniform = true;
292 LastLane = 0;
293 }
294
295 auto *LastInst = cast<Instruction>(get(Def, {Part, LastLane}));
296 // Set the insert point after the last scalarized instruction or after the
297 // last PHI, if LastInst is a PHI. This ensures the insertelement sequence
298 // will directly follow the scalar definitions.
299 auto OldIP = Builder.saveIP();
300 auto NewIP =
301 isa<PHINode>(LastInst)
302 ? BasicBlock::iterator(LastInst->getParent()->getFirstNonPHI())
303 : std::next(BasicBlock::iterator(LastInst));
304 Builder.SetInsertPoint(&*NewIP);
305
306 // However, if we are vectorizing, we need to construct the vector values.
307 // If the value is known to be uniform after vectorization, we can just
308 // broadcast the scalar value corresponding to lane zero for each unroll
309 // iteration. Otherwise, we construct the vector values using
310 // insertelement instructions. Since the resulting vectors are stored in
311 // State, we will only generate the insertelements once.
312 Value *VectorValue = nullptr;
313 if (IsUniform) {
314 VectorValue = GetBroadcastInstrs(ScalarValue);
315 set(Def, VectorValue, Part);
316 } else {
317 // Initialize packing with insertelements to start from undef.
318 assert(!VF.isScalable() && "VF is assumed to be non scalable.");
319 Value *Undef = PoisonValue::get(VectorType::get(LastInst->getType(), VF));
320 set(Def, Undef, Part);
321 for (unsigned Lane = 0; Lane < VF.getKnownMinValue(); ++Lane)
322 packScalarIntoVectorValue(Def, {Part, Lane});
323 VectorValue = get(Def, Part);
324 }
325 Builder.restoreIP(OldIP);
326 return VectorValue;
327}
328
330 VPRegionBlock *LoopRegion = R->getParent()->getEnclosingLoopRegion();
331 return VPBB2IRBB[LoopRegion->getPreheaderVPBB()];
332}
333
335 const Instruction *Orig) {
336 // If the loop was versioned with memchecks, add the corresponding no-alias
337 // metadata.
338 if (LVer && (isa<LoadInst>(Orig) || isa<StoreInst>(Orig)))
339 LVer->annotateInstWithNoAlias(To, Orig);
340}
341
343 // No source instruction to transfer metadata from?
344 if (!From)
345 return;
346
348 addNewMetadata(To, From);
349}
350
352 // No source instruction to transfer metadata from?
353 if (!From)
354 return;
355
356 for (Value *V : To) {
357 if (Instruction *I = dyn_cast<Instruction>(V))
359 }
360}
361
363 const DILocation *DIL = DL;
364 // When a FSDiscriminator is enabled, we don't need to add the multiply
365 // factors to the discriminators.
366 if (DIL &&
368 ->getParent()
371 // FIXME: For scalable vectors, assume vscale=1.
372 auto NewDIL =
374 if (NewDIL)
376 else
377 LLVM_DEBUG(dbgs() << "Failed to create new discriminator: "
378 << DIL->getFilename() << " Line: " << DIL->getLine());
379 } else
381}
382
384 const VPIteration &Instance) {
385 Value *ScalarInst = get(Def, Instance);
386 Value *VectorValue = get(Def, Instance.Part);
387 VectorValue = Builder.CreateInsertElement(
388 VectorValue, ScalarInst, Instance.Lane.getAsRuntimeExpr(Builder, VF));
389 set(Def, VectorValue, Instance.Part);
390}
391
393VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
394 // BB stands for IR BasicBlocks. VPBB stands for VPlan VPBasicBlocks.
395 // Pred stands for Predessor. Prev stands for Previous - last visited/created.
396 BasicBlock *PrevBB = CFG.PrevBB;
397 BasicBlock *NewBB = BasicBlock::Create(PrevBB->getContext(), getName(),
398 PrevBB->getParent(), CFG.ExitBB);
399 LLVM_DEBUG(dbgs() << "LV: created " << NewBB->getName() << '\n');
400
401 // Hook up the new basic block to its predecessors.
402 for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) {
403 VPBasicBlock *PredVPBB = PredVPBlock->getExitingBasicBlock();
404 auto &PredVPSuccessors = PredVPBB->getHierarchicalSuccessors();
405 BasicBlock *PredBB = CFG.VPBB2IRBB[PredVPBB];
406
407 assert(PredBB && "Predecessor basic-block not found building successor.");
408 auto *PredBBTerminator = PredBB->getTerminator();
409 LLVM_DEBUG(dbgs() << "LV: draw edge from" << PredBB->getName() << '\n');
410
411 auto *TermBr = dyn_cast<BranchInst>(PredBBTerminator);
412 if (isa<UnreachableInst>(PredBBTerminator)) {
413 assert(PredVPSuccessors.size() == 1 &&
414 "Predecessor ending w/o branch must have single successor.");
415 DebugLoc DL = PredBBTerminator->getDebugLoc();
416 PredBBTerminator->eraseFromParent();
417 auto *Br = BranchInst::Create(NewBB, PredBB);
418 Br->setDebugLoc(DL);
419 } else if (TermBr && !TermBr->isConditional()) {
420 TermBr->setSuccessor(0, NewBB);
421 } else {
422 // Set each forward successor here when it is created, excluding
423 // backedges. A backward successor is set when the branch is created.
424 unsigned idx = PredVPSuccessors.front() == this ? 0 : 1;
425 assert(!TermBr->getSuccessor(idx) &&
426 "Trying to reset an existing successor block.");
427 TermBr->setSuccessor(idx, NewBB);
428 }
429 }
430 return NewBB;
431}
432
434 bool Replica = State->Instance && !State->Instance->isFirstIteration();
435 VPBasicBlock *PrevVPBB = State->CFG.PrevVPBB;
436 VPBlockBase *SingleHPred = nullptr;
437 BasicBlock *NewBB = State->CFG.PrevBB; // Reuse it if possible.
438
439 auto IsLoopRegion = [](VPBlockBase *BB) {
440 auto *R = dyn_cast<VPRegionBlock>(BB);
441 return R && !R->isReplicator();
442 };
443
444 // 1. Create an IR basic block, or reuse the last one or ExitBB if possible.
445 if (getPlan()->getVectorLoopRegion()->getSingleSuccessor() == this) {
446 // ExitBB can be re-used for the exit block of the Plan.
447 NewBB = State->CFG.ExitBB;
448 State->CFG.PrevBB = NewBB;
449
450 // Update the branch instruction in the predecessor to branch to ExitBB.
451 VPBlockBase *PredVPB = getSingleHierarchicalPredecessor();
452 VPBasicBlock *ExitingVPBB = PredVPB->getExitingBasicBlock();
453 assert(PredVPB->getSingleSuccessor() == this &&
454 "predecessor must have the current block as only successor");
455 BasicBlock *ExitingBB = State->CFG.VPBB2IRBB[ExitingVPBB];
456 // The Exit block of a loop is always set to be successor 0 of the Exiting
457 // block.
458 cast<BranchInst>(ExitingBB->getTerminator())->setSuccessor(0, NewBB);
459 } else if (PrevVPBB && /* A */
460 !((SingleHPred = getSingleHierarchicalPredecessor()) &&
461 SingleHPred->getExitingBasicBlock() == PrevVPBB &&
462 PrevVPBB->getSingleHierarchicalSuccessor() &&
463 (SingleHPred->getParent() == getEnclosingLoopRegion() &&
464 !IsLoopRegion(SingleHPred))) && /* B */
465 !(Replica && getPredecessors().empty())) { /* C */
466 // The last IR basic block is reused, as an optimization, in three cases:
467 // A. the first VPBB reuses the loop pre-header BB - when PrevVPBB is null;
468 // B. when the current VPBB has a single (hierarchical) predecessor which
469 // is PrevVPBB and the latter has a single (hierarchical) successor which
470 // both are in the same non-replicator region; and
471 // C. when the current VPBB is an entry of a region replica - where PrevVPBB
472 // is the exiting VPBB of this region from a previous instance, or the
473 // predecessor of this region.
474
475 NewBB = createEmptyBasicBlock(State->CFG);
476 State->Builder.SetInsertPoint(NewBB);
477 // Temporarily terminate with unreachable until CFG is rewired.
478 UnreachableInst *Terminator = State->Builder.CreateUnreachable();
479 // Register NewBB in its loop. In innermost loops its the same for all
480 // BB's.
481 if (State->CurrentVectorLoop)
482 State->CurrentVectorLoop->addBasicBlockToLoop(NewBB, *State->LI);
483 State->Builder.SetInsertPoint(Terminator);
484 State->CFG.PrevBB = NewBB;
485 }
486
487 // 2. Fill the IR basic block with IR instructions.
488 LLVM_DEBUG(dbgs() << "LV: vectorizing VPBB:" << getName()
489 << " in BB:" << NewBB->getName() << '\n');
490
491 State->CFG.VPBB2IRBB[this] = NewBB;
492 State->CFG.PrevVPBB = this;
493
494 for (VPRecipeBase &Recipe : Recipes)
495 Recipe.execute(*State);
496
497 LLVM_DEBUG(dbgs() << "LV: filled BB:" << *NewBB);
498}
499
501 for (VPRecipeBase &R : Recipes) {
502 for (auto *Def : R.definedValues())
503 Def->replaceAllUsesWith(NewValue);
504
505 for (unsigned I = 0, E = R.getNumOperands(); I != E; I++)
506 R.setOperand(I, NewValue);
507 }
508}
509
511 assert((SplitAt == end() || SplitAt->getParent() == this) &&
512 "can only split at a position in the same block");
513
515 // First, disconnect the current block from its successors.
516 for (VPBlockBase *Succ : Succs)
518
519 // Create new empty block after the block to split.
520 auto *SplitBlock = new VPBasicBlock(getName() + ".split");
522
523 // Add successors for block to split to new block.
524 for (VPBlockBase *Succ : Succs)
526
527 // Finally, move the recipes starting at SplitAt to new block.
528 for (VPRecipeBase &ToMove :
529 make_early_inc_range(make_range(SplitAt, this->end())))
530 ToMove.moveBefore(*SplitBlock, SplitBlock->end());
531
532 return SplitBlock;
533}
534
537 if (P && P->isReplicator()) {
538 P = P->getParent();
539 assert(!cast<VPRegionBlock>(P)->isReplicator() &&
540 "unexpected nested replicate regions");
541 }
542 return P;
543}
544
545static bool hasConditionalTerminator(const VPBasicBlock *VPBB) {
546 if (VPBB->empty()) {
547 assert(
548 VPBB->getNumSuccessors() < 2 &&
549 "block with multiple successors doesn't have a recipe as terminator");
550 return false;
551 }
552
553 const VPRecipeBase *R = &VPBB->back();
554 auto *VPI = dyn_cast<VPInstruction>(R);
555 bool IsCondBranch =
556 isa<VPBranchOnMaskRecipe>(R) ||
557 (VPI && (VPI->getOpcode() == VPInstruction::BranchOnCond ||
558 VPI->getOpcode() == VPInstruction::BranchOnCount));
559 (void)IsCondBranch;
560
561 if (VPBB->getNumSuccessors() >= 2 || VPBB->isExiting()) {
562 assert(IsCondBranch && "block with multiple successors not terminated by "
563 "conditional branch recipe");
564
565 return true;
566 }
567
568 assert(
569 !IsCondBranch &&
570 "block with 0 or 1 successors terminated by conditional branch recipe");
571 return false;
572}
573
575 if (hasConditionalTerminator(this))
576 return &back();
577 return nullptr;
578}
579
581 if (hasConditionalTerminator(this))
582 return &back();
583 return nullptr;
584}
585
587 return getParent()->getExitingBasicBlock() == this;
588}
589
590#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
591void VPBlockBase::printSuccessors(raw_ostream &O, const Twine &Indent) const {
592 if (getSuccessors().empty()) {
593 O << Indent << "No successors\n";
594 } else {
595 O << Indent << "Successor(s): ";
596 ListSeparator LS;
597 for (auto *Succ : getSuccessors())
598 O << LS << Succ->getName();
599 O << '\n';
600 }
601}
602
603void VPBasicBlock::print(raw_ostream &O, const Twine &Indent,
604 VPSlotTracker &SlotTracker) const {
605 O << Indent << getName() << ":\n";
606
607 auto RecipeIndent = Indent + " ";
608 for (const VPRecipeBase &Recipe : *this) {
609 Recipe.print(O, RecipeIndent, SlotTracker);
610 O << '\n';
611 }
612
613 printSuccessors(O, Indent);
614}
615#endif
616
619 // Drop all references in VPBasicBlocks and replace all uses with
620 // DummyValue.
621 Block->dropAllReferences(NewValue);
622}
623
626 RPOT(Entry);
627
628 if (!isReplicator()) {
629 // Create and register the new vector loop.
630 Loop *PrevLoop = State->CurrentVectorLoop;
631 State->CurrentVectorLoop = State->LI->AllocateLoop();
632 BasicBlock *VectorPH = State->CFG.VPBB2IRBB[getPreheaderVPBB()];
633 Loop *ParentLoop = State->LI->getLoopFor(VectorPH);
634
635 // Insert the new loop into the loop nest and register the new basic blocks
636 // before calling any utilities such as SCEV that require valid LoopInfo.
637 if (ParentLoop)
638 ParentLoop->addChildLoop(State->CurrentVectorLoop);
639 else
640 State->LI->addTopLevelLoop(State->CurrentVectorLoop);
641
642 // Visit the VPBlocks connected to "this", starting from it.
643 for (VPBlockBase *Block : RPOT) {
644 LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n');
645 Block->execute(State);
646 }
647
648 State->CurrentVectorLoop = PrevLoop;
649 return;
650 }
651
652 assert(!State->Instance && "Replicating a Region with non-null instance.");
653
654 // Enter replicating mode.
655 State->Instance = VPIteration(0, 0);
656
657 for (unsigned Part = 0, UF = State->UF; Part < UF; ++Part) {
658 State->Instance->Part = Part;
659 assert(!State->VF.isScalable() && "VF is assumed to be non scalable.");
660 for (unsigned Lane = 0, VF = State->VF.getKnownMinValue(); Lane < VF;
661 ++Lane) {
662 State->Instance->Lane = VPLane(Lane, VPLane::Kind::First);
663 // Visit the VPBlocks connected to \p this, starting from it.
664 for (VPBlockBase *Block : RPOT) {
665 LLVM_DEBUG(dbgs() << "LV: VPBlock in RPO " << Block->getName() << '\n');
666 Block->execute(State);
667 }
668 }
669 }
670
671 // Exit replicating mode.
672 State->Instance.reset();
673}
674
675#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
677 VPSlotTracker &SlotTracker) const {
678 O << Indent << (isReplicator() ? "<xVFxUF> " : "<x1> ") << getName() << ": {";
679 auto NewIndent = Indent + " ";
680 for (auto *BlockBase : vp_depth_first_shallow(Entry)) {
681 O << '\n';
682 BlockBase->print(O, NewIndent, SlotTracker);
683 }
684 O << Indent << "}\n";
685
686 printSuccessors(O, Indent);
687}
688#endif
689
691 for (auto &KV : LiveOuts)
692 delete KV.second;
693 LiveOuts.clear();
694
695 if (Entry) {
696 VPValue DummyValue;
698 Block->dropAllReferences(&DummyValue);
699
701
702 Preheader->dropAllReferences(&DummyValue);
703 delete Preheader;
704 }
705 for (VPValue *VPV : VPLiveInsToFree)
706 delete VPV;
707 if (BackedgeTakenCount)
708 delete BackedgeTakenCount;
709}
710
712 VPBasicBlock *Preheader = new VPBasicBlock("ph");
713 VPBasicBlock *VecPreheader = new VPBasicBlock("vector.ph");
714 auto Plan = std::make_unique<VPlan>(Preheader, VecPreheader);
715 Plan->TripCount =
717 // Create empty VPRegionBlock, to be filled during processing later.
718 auto *TopRegion = new VPRegionBlock("vector loop", false /*isReplicator*/);
719 VPBlockUtils::insertBlockAfter(TopRegion, VecPreheader);
720 VPBasicBlock *MiddleVPBB = new VPBasicBlock("middle.block");
721 VPBlockUtils::insertBlockAfter(MiddleVPBB, TopRegion);
722 return Plan;
723}
724
725void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
726 Value *CanonicalIVStartValue,
727 VPTransformState &State) {
728 // Check if the backedge taken count is needed, and if so build it.
729 if (BackedgeTakenCount && BackedgeTakenCount->getNumUsers()) {
731 auto *TCMO = Builder.CreateSub(TripCountV,
732 ConstantInt::get(TripCountV->getType(), 1),
733 "trip.count.minus.1");
734 auto VF = State.VF;
735 Value *VTCMO =
736 VF.isScalar() ? TCMO : Builder.CreateVectorSplat(VF, TCMO, "broadcast");
737 for (unsigned Part = 0, UF = State.UF; Part < UF; ++Part)
738 State.set(BackedgeTakenCount, VTCMO, Part);
739 }
740
741 for (unsigned Part = 0, UF = State.UF; Part < UF; ++Part)
742 State.set(&VectorTripCount, VectorTripCountV, Part);
743
744 // When vectorizing the epilogue loop, the canonical induction start value
745 // needs to be changed from zero to the value after the main vector loop.
746 // FIXME: Improve modeling for canonical IV start values in the epilogue loop.
747 if (CanonicalIVStartValue) {
748 VPValue *VPV = getVPValueOrAddLiveIn(CanonicalIVStartValue);
749 auto *IV = getCanonicalIV();
750 assert(all_of(IV->users(),
751 [](const VPUser *U) {
752 return isa<VPScalarIVStepsRecipe>(U) ||
753 isa<VPDerivedIVRecipe>(U) ||
754 cast<VPInstruction>(U)->getOpcode() ==
755 VPInstruction::CanonicalIVIncrement;
756 }) &&
757 "the canonical IV should only be used by its increment or "
758 "ScalarIVSteps when resetting the start value");
759 IV->setOperand(0, VPV);
760 }
761}
762
763/// Generate the code inside the preheader and body of the vectorized loop.
764/// Assumes a single pre-header basic-block was created for this. Introduce
765/// additional basic-blocks as needed, and fill them all.
767 // Set the reverse mapping from VPValues to Values for code generation.
768 for (auto &Entry : Value2VPValue)
769 State->VPValue2Value[Entry.second] = Entry.first;
770
771 // Initialize CFG state.
772 State->CFG.PrevVPBB = nullptr;
773 State->CFG.ExitBB = State->CFG.PrevBB->getSingleSuccessor();
774 BasicBlock *VectorPreHeader = State->CFG.PrevBB;
775 State->Builder.SetInsertPoint(VectorPreHeader->getTerminator());
776
777 // Generate code in the loop pre-header and body.
779 Block->execute(State);
780
781 VPBasicBlock *LatchVPBB = getVectorLoopRegion()->getExitingBasicBlock();
782 BasicBlock *VectorLatchBB = State->CFG.VPBB2IRBB[LatchVPBB];
783
784 // Fix the latch value of canonical, reduction and first-order recurrences
785 // phis in the vector loop.
786 VPBasicBlock *Header = getVectorLoopRegion()->getEntryBasicBlock();
787 for (VPRecipeBase &R : Header->phis()) {
788 // Skip phi-like recipes that generate their backedege values themselves.
789 if (isa<VPWidenPHIRecipe>(&R))
790 continue;
791
792 if (isa<VPWidenPointerInductionRecipe>(&R) ||
793 isa<VPWidenIntOrFpInductionRecipe>(&R)) {
794 PHINode *Phi = nullptr;
795 if (isa<VPWidenIntOrFpInductionRecipe>(&R)) {
796 Phi = cast<PHINode>(State->get(R.getVPSingleValue(), 0));
797 } else {
798 auto *WidenPhi = cast<VPWidenPointerInductionRecipe>(&R);
799 // TODO: Split off the case that all users of a pointer phi are scalar
800 // from the VPWidenPointerInductionRecipe.
801 if (WidenPhi->onlyScalarsGenerated(State->VF))
802 continue;
803
804 auto *GEP = cast<GetElementPtrInst>(State->get(WidenPhi, 0));
805 Phi = cast<PHINode>(GEP->getPointerOperand());
806 }
807
808 Phi->setIncomingBlock(1, VectorLatchBB);
809
810 // Move the last step to the end of the latch block. This ensures
811 // consistent placement of all induction updates.
812 Instruction *Inc = cast<Instruction>(Phi->getIncomingValue(1));
813 Inc->moveBefore(VectorLatchBB->getTerminator()->getPrevNode());
814 continue;
815 }
816
817 auto *PhiR = cast<VPHeaderPHIRecipe>(&R);
818 // For canonical IV, first-order recurrences and in-order reduction phis,
819 // only a single part is generated, which provides the last part from the
820 // previous iteration. For non-ordered reductions all UF parts are
821 // generated.
822 bool SinglePartNeeded = isa<VPCanonicalIVPHIRecipe>(PhiR) ||
823 isa<VPFirstOrderRecurrencePHIRecipe>(PhiR) ||
824 (isa<VPReductionPHIRecipe>(PhiR) &&
825 cast<VPReductionPHIRecipe>(PhiR)->isOrdered());
826 unsigned LastPartForNewPhi = SinglePartNeeded ? 1 : State->UF;
827
828 for (unsigned Part = 0; Part < LastPartForNewPhi; ++Part) {
829 Value *Phi = State->get(PhiR, Part);
830 Value *Val = State->get(PhiR->getBackedgeValue(),
831 SinglePartNeeded ? State->UF - 1 : Part);
832 cast<PHINode>(Phi)->addIncoming(Val, VectorLatchBB);
833 }
834 }
835
836 // We do not attempt to preserve DT for outer loop vectorization currently.
838 BasicBlock *VectorHeaderBB = State->CFG.VPBB2IRBB[Header];
839 State->DT->addNewBlock(VectorHeaderBB, VectorPreHeader);
840 updateDominatorTree(State->DT, VectorHeaderBB, VectorLatchBB,
841 State->CFG.ExitBB);
842 }
843}
844
845#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
847void VPlan::print(raw_ostream &O) const {
849
850 O << "VPlan '" << getName() << "' {";
851
852 if (VectorTripCount.getNumUsers() > 0) {
853 O << "\nLive-in ";
854 VectorTripCount.printAsOperand(O, SlotTracker);
855 O << " = vector-trip-count";
856 }
857
858 if (BackedgeTakenCount && BackedgeTakenCount->getNumUsers()) {
859 O << "\nLive-in ";
860 BackedgeTakenCount->printAsOperand(O, SlotTracker);
861 O << " = backedge-taken count";
862 }
863
864 O << "\n";
865 if (TripCount->isLiveIn())
866 O << "Live-in ";
867 TripCount->printAsOperand(O, SlotTracker);
868 O << " = original trip-count";
869 O << "\n";
870
871 if (!getPreheader()->empty()) {
872 O << "\n";
873 getPreheader()->print(O, "", SlotTracker);
874 }
875
876 for (const VPBlockBase *Block : vp_depth_first_shallow(getEntry())) {
877 O << '\n';
878 Block->print(O, "", SlotTracker);
879 }
880
881 if (!LiveOuts.empty())
882 O << "\n";
883 for (const auto &KV : LiveOuts) {
884 KV.second->print(O, SlotTracker);
885 }
886
887 O << "}\n";
888}
889
890std::string VPlan::getName() const {
891 std::string Out;
892 raw_string_ostream RSO(Out);
893 RSO << Name << " for ";
894 if (!VFs.empty()) {
895 RSO << "VF={" << VFs[0];
896 for (ElementCount VF : drop_begin(VFs))
897 RSO << "," << VF;
898 RSO << "},";
899 }
900
901 if (UFs.empty()) {
902 RSO << "UF>=1";
903 } else {
904 RSO << "UF={" << UFs[0];
905 for (unsigned UF : drop_begin(UFs))
906 RSO << "," << UF;
907 RSO << "}";
908 }
909
910 return Out;
911}
912
915 VPlanPrinter Printer(O, *this);
916 Printer.dump();
917}
918
920void VPlan::dump() const { print(dbgs()); }
921#endif
922
924 assert(LiveOuts.count(PN) == 0 && "an exit value for PN already exists");
925 LiveOuts.insert({PN, new VPLiveOut(PN, V)});
926}
927
928void VPlan::updateDominatorTree(DominatorTree *DT, BasicBlock *LoopHeaderBB,
929 BasicBlock *LoopLatchBB,
930 BasicBlock *LoopExitBB) {
931 // The vector body may be more than a single basic-block by this point.
932 // Update the dominator tree information inside the vector body by propagating
933 // it from header to latch, expecting only triangular control-flow, if any.
934 BasicBlock *PostDomSucc = nullptr;
935 for (auto *BB = LoopHeaderBB; BB != LoopLatchBB; BB = PostDomSucc) {
936 // Get the list of successors of this block.
937 std::vector<BasicBlock *> Succs(succ_begin(BB), succ_end(BB));
938 assert(Succs.size() <= 2 &&
939 "Basic block in vector loop has more than 2 successors.");
940 PostDomSucc = Succs[0];
941 if (Succs.size() == 1) {
942 assert(PostDomSucc->getSinglePredecessor() &&
943 "PostDom successor has more than one predecessor.");
944 DT->addNewBlock(PostDomSucc, BB);
945 continue;
946 }
947 BasicBlock *InterimSucc = Succs[1];
948 if (PostDomSucc->getSingleSuccessor() == InterimSucc) {
949 PostDomSucc = Succs[1];
950 InterimSucc = Succs[0];
951 }
952 assert(InterimSucc->getSingleSuccessor() == PostDomSucc &&
953 "One successor of a basic block does not lead to the other.");
954 assert(InterimSucc->getSinglePredecessor() &&
955 "Interim successor has more than one predecessor.");
956 assert(PostDomSucc->hasNPredecessors(2) &&
957 "PostDom successor has more than two predecessors.");
958 DT->addNewBlock(InterimSucc, BB);
959 DT->addNewBlock(PostDomSucc, BB);
960 }
961 // Latch block is a new dominator for the loop exit.
962 DT->changeImmediateDominator(LoopExitBB, LoopLatchBB);
963 assert(DT->verify(DominatorTree::VerificationLevel::Fast));
964}
965
966#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
967
968Twine VPlanPrinter::getUID(const VPBlockBase *Block) {
969 return (isa<VPRegionBlock>(Block) ? "cluster_N" : "N") +
970 Twine(getOrCreateBID(Block));
971}
972
973Twine VPlanPrinter::getOrCreateName(const VPBlockBase *Block) {
974 const std::string &Name = Block->getName();
975 if (!Name.empty())
976 return Name;
977 return "VPB" + Twine(getOrCreateBID(Block));
978}
979
981 Depth = 1;
982 bumpIndent(0);
983 OS << "digraph VPlan {\n";
984 OS << "graph [labelloc=t, fontsize=30; label=\"Vectorization Plan";
985 if (!Plan.getName().empty())
986 OS << "\\n" << DOT::EscapeString(Plan.getName());
987 if (Plan.BackedgeTakenCount) {
988 OS << ", where:\\n";
989 Plan.BackedgeTakenCount->print(OS, SlotTracker);
990 OS << " := BackedgeTakenCount";
991 }
992 OS << "\"]\n";
993 OS << "node [shape=rect, fontname=Courier, fontsize=30]\n";
994 OS << "edge [fontname=Courier, fontsize=30]\n";
995 OS << "compound=true\n";
996
997 dumpBlock(Plan.getPreheader());
998
1000 dumpBlock(Block);
1001
1002 OS << "}\n";
1003}
1004
1005void VPlanPrinter::dumpBlock(const VPBlockBase *Block) {
1006 if (const VPBasicBlock *BasicBlock = dyn_cast<VPBasicBlock>(Block))
1007 dumpBasicBlock(BasicBlock);
1008 else if (const VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
1009 dumpRegion(Region);
1010 else
1011 llvm_unreachable("Unsupported kind of VPBlock.");
1012}
1013
1014void VPlanPrinter::drawEdge(const VPBlockBase *From, const VPBlockBase *To,
1015 bool Hidden, const Twine &Label) {
1016 // Due to "dot" we print an edge between two regions as an edge between the
1017 // exiting basic block and the entry basic of the respective regions.
1018 const VPBlockBase *Tail = From->getExitingBasicBlock();
1019 const VPBlockBase *Head = To->getEntryBasicBlock();
1020 OS << Indent << getUID(Tail) << " -> " << getUID(Head);
1021 OS << " [ label=\"" << Label << '\"';
1022 if (Tail != From)
1023 OS << " ltail=" << getUID(From);
1024 if (Head != To)
1025 OS << " lhead=" << getUID(To);
1026 if (Hidden)
1027 OS << "; splines=none";
1028 OS << "]\n";
1029}
1030
1031void VPlanPrinter::dumpEdges(const VPBlockBase *Block) {
1032 auto &Successors = Block->getSuccessors();
1033 if (Successors.size() == 1)
1034 drawEdge(Block, Successors.front(), false, "");
1035 else if (Successors.size() == 2) {
1036 drawEdge(Block, Successors.front(), false, "T");
1037 drawEdge(Block, Successors.back(), false, "F");
1038 } else {
1039 unsigned SuccessorNumber = 0;
1040 for (auto *Successor : Successors)
1041 drawEdge(Block, Successor, false, Twine(SuccessorNumber++));
1042 }
1043}
1044
1045void VPlanPrinter::dumpBasicBlock(const VPBasicBlock *BasicBlock) {
1046 // Implement dot-formatted dump by performing plain-text dump into the
1047 // temporary storage followed by some post-processing.
1048 OS << Indent << getUID(BasicBlock) << " [label =\n";
1049 bumpIndent(1);
1050 std::string Str;
1052 // Use no indentation as we need to wrap the lines into quotes ourselves.
1053 BasicBlock->print(SS, "", SlotTracker);
1054
1055 // We need to process each line of the output separately, so split
1056 // single-string plain-text dump.
1058 StringRef(Str).rtrim('\n').split(Lines, "\n");
1059
1060 auto EmitLine = [&](StringRef Line, StringRef Suffix) {
1061 OS << Indent << '"' << DOT::EscapeString(Line.str()) << "\\l\"" << Suffix;
1062 };
1063
1064 // Don't need the "+" after the last line.
1065 for (auto Line : make_range(Lines.begin(), Lines.end() - 1))
1066 EmitLine(Line, " +\n");
1067 EmitLine(Lines.back(), "\n");
1068
1069 bumpIndent(-1);
1070 OS << Indent << "]\n";
1071
1073}
1074
1075void VPlanPrinter::dumpRegion(const VPRegionBlock *Region) {
1076 OS << Indent << "subgraph " << getUID(Region) << " {\n";
1077 bumpIndent(1);
1078 OS << Indent << "fontname=Courier\n"
1079 << Indent << "label=\""
1080 << DOT::EscapeString(Region->isReplicator() ? "<xVFxUF> " : "<x1> ")
1081 << DOT::EscapeString(Region->getName()) << "\"\n";
1082 // Dump the blocks of the region.
1083 assert(Region->getEntry() && "Region contains no inner blocks.");
1085 dumpBlock(Block);
1086 bumpIndent(-1);
1087 OS << Indent << "}\n";
1089}
1090
1092 if (auto *Inst = dyn_cast<Instruction>(V)) {
1093 if (!Inst->getType()->isVoidTy()) {
1094 Inst->printAsOperand(O, false);
1095 O << " = ";
1096 }
1097 O << Inst->getOpcodeName() << " ";
1098 unsigned E = Inst->getNumOperands();
1099 if (E > 0) {
1100 Inst->getOperand(0)->printAsOperand(O, false);
1101 for (unsigned I = 1; I < E; ++I)
1102 Inst->getOperand(I)->printAsOperand(O << ", ", false);
1103 }
1104 } else // !Inst
1105 V->printAsOperand(O, false);
1106}
1107
1108#endif
1109
1110template void DomTreeBuilder::Calculate<VPDominatorTree>(VPDominatorTree &DT);
1111
1113 for (unsigned J = 0; J < getNumUsers();) {
1114 VPUser *User = Users[J];
1115 unsigned NumUsers = getNumUsers();
1116 for (unsigned I = 0, E = User->getNumOperands(); I < E; ++I)
1117 if (User->getOperand(I) == this)
1118 User->setOperand(I, New);
1119 // If a user got removed after updating the current user, the next user to
1120 // update will be moved to the current position, so we only need to
1121 // increment the index if the number of users did not change.
1122 if (NumUsers == getNumUsers())
1123 J++;
1124 }
1125}
1126
1128 VPValue *New,
1129 llvm::function_ref<bool(VPUser &U, unsigned Idx)> ShouldReplace) {
1130 for (unsigned J = 0; J < getNumUsers();) {
1131 VPUser *User = Users[J];
1132 unsigned NumUsers = getNumUsers();
1133 for (unsigned I = 0, E = User->getNumOperands(); I < E; ++I) {
1134 if (User->getOperand(I) != this || !ShouldReplace(*User, I))
1135 continue;
1136
1137 User->setOperand(I, New);
1138 }
1139 // If a user got removed after updating the current user, the next user to
1140 // update will be moved to the current position, so we only need to
1141 // increment the index if the number of users did not change.
1142 if (NumUsers == getNumUsers())
1143 J++;
1144 }
1145}
1146
1147#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1149 if (const Value *UV = getUnderlyingValue()) {
1150 OS << "ir<";
1151 UV->printAsOperand(OS, false);
1152 OS << ">";
1153 return;
1154 }
1155
1156 unsigned Slot = Tracker.getSlot(this);
1157 if (Slot == unsigned(-1))
1158 OS << "<badref>";
1159 else
1160 OS << "vp<%" << Tracker.getSlot(this) << ">";
1161}
1162
1164 interleaveComma(operands(), O, [&O, &SlotTracker](VPValue *Op) {
1165 Op->printAsOperand(O, SlotTracker);
1166 });
1167}
1168#endif
1169
1170void VPInterleavedAccessInfo::visitRegion(VPRegionBlock *Region,
1171 Old2NewTy &Old2New,
1172 InterleavedAccessInfo &IAI) {
1174 RPOT(Region->getEntry());
1175 for (VPBlockBase *Base : RPOT) {
1176 visitBlock(Base, Old2New, IAI);
1177 }
1178}
1179
1180void VPInterleavedAccessInfo::visitBlock(VPBlockBase *Block, Old2NewTy &Old2New,
1181 InterleavedAccessInfo &IAI) {
1182 if (VPBasicBlock *VPBB = dyn_cast<VPBasicBlock>(Block)) {
1183 for (VPRecipeBase &VPI : *VPBB) {
1184 if (isa<VPHeaderPHIRecipe>(&VPI))
1185 continue;
1186 assert(isa<VPInstruction>(&VPI) && "Can only handle VPInstructions");
1187 auto *VPInst = cast<VPInstruction>(&VPI);
1188
1189 auto *Inst = dyn_cast_or_null<Instruction>(VPInst->getUnderlyingValue());
1190 if (!Inst)
1191 continue;
1192 auto *IG = IAI.getInterleaveGroup(Inst);
1193 if (!IG)
1194 continue;
1195
1196 auto NewIGIter = Old2New.find(IG);
1197 if (NewIGIter == Old2New.end())
1198 Old2New[IG] = new InterleaveGroup<VPInstruction>(
1199 IG->getFactor(), IG->isReverse(), IG->getAlign());
1200
1201 if (Inst == IG->getInsertPos())
1202 Old2New[IG]->setInsertPos(VPInst);
1203
1204 InterleaveGroupMap[VPInst] = Old2New[IG];
1205 InterleaveGroupMap[VPInst]->insertMember(
1206 VPInst, IG->getIndex(Inst),
1207 Align(IG->isReverse() ? (-1) * int(IG->getFactor())
1208 : IG->getFactor()));
1209 }
1210 } else if (VPRegionBlock *Region = dyn_cast<VPRegionBlock>(Block))
1211 visitRegion(Region, Old2New, IAI);
1212 else
1213 llvm_unreachable("Unsupported kind of VPBlock.");
1214}
1215
1217 InterleavedAccessInfo &IAI) {
1218 Old2NewTy Old2New;
1219 visitRegion(Plan.getVectorLoopRegion(), Old2New, IAI);
1220}
1221
1222void VPSlotTracker::assignSlot(const VPValue *V) {
1223 assert(!Slots.contains(V) && "VPValue already has a slot!");
1224 Slots[V] = NextSlot++;
1225}
1226
1227void VPSlotTracker::assignSlots(const VPlan &Plan) {
1228 assignSlot(&Plan.VectorTripCount);
1229 if (Plan.BackedgeTakenCount)
1230 assignSlot(Plan.BackedgeTakenCount);
1231 assignSlots(Plan.getPreheader());
1232
1235 for (const VPBasicBlock *VPBB :
1236 VPBlockUtils::blocksOnly<const VPBasicBlock>(RPOT))
1237 assignSlots(VPBB);
1238}
1239
1240void VPSlotTracker::assignSlots(const VPBasicBlock *VPBB) {
1241 for (const VPRecipeBase &Recipe : *VPBB)
1242 for (VPValue *Def : Recipe.definedValues())
1243 assignSlot(Def);
1244}
1245
1247 return all_of(Def->users(),
1248 [Def](VPUser *U) { return U->onlyFirstLaneUsed(Def); });
1249}
1250
1252 ScalarEvolution &SE) {
1253 if (auto *Expanded = Plan.getSCEVExpansion(Expr))
1254 return Expanded;
1255 VPValue *Expanded = nullptr;
1256 if (auto *E = dyn_cast<SCEVConstant>(Expr))
1257 Expanded = Plan.getVPValueOrAddLiveIn(E->getValue());
1258 else if (auto *E = dyn_cast<SCEVUnknown>(Expr))
1259 Expanded = Plan.getVPValueOrAddLiveIn(E->getValue());
1260 else {
1261 Expanded = new VPExpandSCEVRecipe(Expr, SE);
1263 }
1264 Plan.addSCEVExpansion(Expr, Expanded);
1265 return Expanded;
1266}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:510
dxil pretty DXIL Metadata Pretty Printer
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define LLVM_DEBUG(X)
Definition: Debug.h:101
std::string Name
static void dumpEdges(CFGMST< Edge, BBInfo > &MST, GCOVFunction &GF)
Generic dominator tree construction - this file provides routines to construct immediate dominator in...
Hexagon Common GEP
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
iv Induction Variable Users
Definition: IVUsers.cpp:48
#define I(x, y, z)
Definition: MD5.cpp:58
#define P(N)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
static T * getPlanEntry(T *Start)
Definition: VPlan.cpp:126
static bool hasConditionalTerminator(const VPBasicBlock *VPBB)
Definition: VPlan.cpp:545
This file contains the declarations of the Vectorization Plan base classes:
static bool IsCondBranch(unsigned BrOpc)
static const uint32_t IV[8]
Definition: blake3_impl.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
iterator end()
Definition: BasicBlock.h:450
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the basic block to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4683
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:206
bool hasNPredecessors(unsigned N) const
Return true if this block has exactly N predecessors.
Definition: BasicBlock.cpp:511
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
Definition: BasicBlock.cpp:489
const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
Definition: BasicBlock.cpp:519
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:213
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:173
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:207
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.h:228
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:888
Debug location.
std::optional< const DILocation * > cloneByMultiplyingDuplicationFactor(unsigned DF) const
Returns a new DILocation with duplication factor DF * current duplication factor encoded in the discr...
This class represents an Operation in the Expression.
A debug info location.
Definition: DebugLoc.h:33
Core dominator tree base class.
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
void changeImmediateDominator(DomTreeNodeBase< NodeT > *N, DomTreeNodeBase< NodeT > *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
DomTreeNodeBase< NodeT > * addNewBlock(NodeT *BB, NodeT *DomBB)
Add a new node to the dominator tree information.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:165
constexpr bool isScalar() const
Exactly one element.
Definition: TypeSize.h:308
bool shouldEmitDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
Definition: Metadata.cpp:1780
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:94
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2445
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition: IRBuilder.h:2433
UnreachableInst * CreateUnreachable()
Definition: IRBuilder.h:1257
Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Definition: IRBuilder.cpp:1212
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Definition: IRBuilder.h:520
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:174
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:220
InsertPoint saveIP() const
Returns the current insert point.
Definition: IRBuilder.h:271
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:480
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1338
void restoreIP(InsertPoint IP)
Sets the current insert point to a previously-saved location.
Definition: IRBuilder.h:283
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition: IRBuilder.h:180
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2639
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
The group of interleaved loads/stores sharing the same stride and close to each other.
Definition: VectorUtils.h:614
Drive the analysis of interleaved memory accesses in the loop.
Definition: VectorUtils.h:756
InterleaveGroup< Instruction > * getInterleaveGroup(const Instruction *Instr) const
Get the interleave group that Instr belongs to.
Definition: VectorUtils.h:801
void addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
This method is used by other analyses to update loop information.
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
LoopT * AllocateLoop(ArgsTy &&...Args)
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
void annotateInstWithNoAlias(Instruction *VersionedInst, const Instruction *OrigInst)
Add the noalias annotations to VersionedInst.
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:44
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
void dump() const
User-friendly dump.
Definition: AsmWriter.cpp:5105
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1743
BlockT * getEntry() const
Get the entry BasicBlock of the Region.
Definition: RegionInfo.h:322
This class represents an analyzed expression in the program.
The main scalar evolution driver.
size_type size() const
Determine the number of elements in the SetVector.
Definition: SetVector.h:98
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:162
This class provides computation of slot numbers for LLVM Assembly writing.
Definition: AsmWriter.cpp:689
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:370
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:704
StringRef rtrim(char Char) const
Return string with consecutive Char characters starting from the right removed.
Definition: StringRef.h:807
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
This function has undefined behavior.
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
Value * getOperand(unsigned i) const
Definition: User.h:169
unsigned getNumOperands() const
Definition: User.h:191
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:2260
void appendRecipe(VPRecipeBase *Recipe)
Augment the existing recipes of a VPBasicBlock with an additional Recipe as the last recipe.
Definition: VPlan.h:2328
RecipeListTy::iterator iterator
Instruction iterators...
Definition: VPlan.h:2281
void execute(VPTransformState *State) override
The method which generates the output IR instructions that correspond to this VPBasicBlock,...
Definition: VPlan.cpp:433
iterator end()
Definition: VPlan.h:2291
iterator begin()
Recipe iterator methods.
Definition: VPlan.h:2289
iterator getFirstNonPhi()
Return the position of the first non-phi node recipe in the block.
Definition: VPlan.cpp:208
VPRegionBlock * getEnclosingLoopRegion()
Definition: VPlan.cpp:535
void dropAllReferences(VPValue *NewValue) override
Replace all operands of VPUsers in the block with NewValue and also replaces all uses of VPValues def...
Definition: VPlan.cpp:500
VPBasicBlock * splitAt(iterator SplitAt)
Split current block at SplitAt by inserting a new block between the current block and its successors ...
Definition: VPlan.cpp:510
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print this VPBsicBlock to O, prefixing all lines with Indent.
Definition: VPlan.cpp:603
bool isExiting() const
Returns true if the block is exiting it's parent region.
Definition: VPlan.cpp:586
VPRecipeBase * getTerminator()
If the block has multiple successors, return the branch recipe terminating the block.
Definition: VPlan.cpp:574
const VPRecipeBase & back() const
Definition: VPlan.h:2303
bool empty() const
Definition: VPlan.h:2300
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Definition: VPlan.h:420
VPRegionBlock * getParent()
Definition: VPlan.h:492
const VPBasicBlock * getExitingBasicBlock() const
Definition: VPlan.cpp:173
size_t getNumSuccessors() const
Definition: VPlan.h:537
void printSuccessors(raw_ostream &O, const Twine &Indent) const
Print the successors of this block to O, prefixing all lines with Indent.
Definition: VPlan.cpp:591
VPBlockBase * getEnclosingBlockWithPredecessors()
Definition: VPlan.cpp:195
static void deleteCFG(VPBlockBase *Entry)
Delete all blocks reachable from a given VPBlockBase, inclusive.
Definition: VPlan.cpp:203
VPlan * getPlan()
Definition: VPlan.cpp:146
void setPlan(VPlan *ParentPlan)
Sets the pointer of the plan containing the block.
Definition: VPlan.cpp:165
VPBlockBase * getSingleHierarchicalSuccessor()
Definition: VPlan.h:563
VPBlockBase * getSinglePredecessor() const
Definition: VPlan.h:533
const VPBlocksTy & getHierarchicalSuccessors()
Definition: VPlan.h:557
VPBlockBase * getEnclosingBlockWithSuccessors()
An Enclosing Block of a block B is any block containing B, including B itself.
Definition: VPlan.cpp:187
const VPBasicBlock * getEntryBasicBlock() const
Definition: VPlan.cpp:151
VPBlockBase * getSingleSuccessor() const
Definition: VPlan.h:527
Helper for GraphTraits specialization that traverses through VPRegionBlocks.
Definition: VPlanCFG.h:115
static void insertBlockAfter(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)
Insert disconnected VPBlockBase NewBlock after BlockPtr.
Definition: VPlan.h:2809
static void disconnectBlocks(VPBlockBase *From, VPBlockBase *To)
Disconnect VPBlockBases From and To bi-directionally.
Definition: VPlan.h:2856
static void connectBlocks(VPBlockBase *From, VPBlockBase *To)
Connect VPBlockBases From and To bi-directionally.
Definition: VPlan.h:2845
This class augments a recipe with a set of VPValues defined by the recipe.
Definition: VPlanValue.h:313
void dump() const
Dump the VPDef to stderr (for debugging).
Definition: VPlan.cpp:107
virtual void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const =0
Each concrete VPDef prints itself.
Recipe to expand a SCEV expression.
Definition: VPlan.h:2033
This is a concrete Recipe that models a single VPlan-level instruction.
Definition: VPlan.h:1018
VPInterleavedAccessInfo(VPlan &Plan, InterleavedAccessInfo &IAI)
Definition: VPlan.cpp:1216
In what follows, the term "input IR" refers to code that is fed into the vectorizer whereas the term ...
Definition: VPlan.h:141
Value * getAsRuntimeExpr(IRBuilderBase &Builder, const ElementCount &VF) const
Returns an expression describing the lane index that can be used at runtime.
Definition: VPlan.cpp:66
@ ScalableLast
For ScalableLast, Lane is the offset from the start of the last N-element subvector in a scalable vec...
@ First
For First, Lane is the index into the first N elements of a fixed-vector <N x <ElTy>> or a scalable v...
A value that is used outside the VPlan.
Definition: VPlan.h:667
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Definition: VPlan.h:707
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
Definition: VPlan.h:2384
const VPBlockBase * getEntry() const
Definition: VPlan.h:2423
void dropAllReferences(VPValue *NewValue) override
Replace all operands of VPUsers in the block with NewValue and also replaces all uses of VPValues def...
Definition: VPlan.cpp:617
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print this VPRegionBlock to O (recursively), prefixing all lines with Indent.
Definition: VPlan.cpp:676
void execute(VPTransformState *State) override
The method which generates the output IR instructions that correspond to this VPRegionBlock,...
Definition: VPlan.cpp:624
const VPBlockBase * getExiting() const
Definition: VPlan.h:2435
VPBasicBlock * getPreheaderVPBB()
Returns the pre-header VPBasicBlock of the loop region.
Definition: VPlan.h:2448
This class can be used to assign consecutive numbers to all VPValues in a VPlan and allows querying t...
Definition: VPlanValue.h:445
unsigned getSlot(const VPValue *V) const
Definition: VPlanValue.h:459
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
Definition: VPlanValue.h:211
void printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const
Print the operands to O.
Definition: VPlan.cpp:1163
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Definition: VPlan.cpp:116
void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const
Definition: VPlan.cpp:1148
void dump() const
Dump the value to stderr (for debugging).
Definition: VPlan.cpp:99
VPValue(const unsigned char SC, Value *UV=nullptr, VPDef *Def=nullptr)
Definition: VPlan.cpp:79
virtual ~VPValue()
Definition: VPlan.cpp:85
void print(raw_ostream &OS, VPSlotTracker &Tracker) const
Definition: VPlan.cpp:92
void replaceAllUsesWith(VPValue *New)
Definition: VPlan.cpp:1112
void replaceUsesWithIf(VPValue *New, llvm::function_ref< bool(VPUser &U, unsigned Idx)> ShouldReplace)
Go through the uses list for this VPValue and make each use point to New if the callback ShouldReplac...
Definition: VPlan.cpp:1127
VPDef * Def
Pointer to the VPDef that defines this VPValue.
Definition: VPlanValue.h:65
VPlanPrinter prints a given VPlan to a given output stream.
Definition: VPlan.h:2729
LLVM_DUMP_METHOD void dump()
Definition: VPlan.cpp:980
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:2481
void printDOT(raw_ostream &O) const
Print this VPlan in DOT format to O.
Definition: VPlan.cpp:914
std::string getName() const
Return a string with the name of the plan and the applicable VFs and UFs.
Definition: VPlan.cpp:890
void prepareToExecute(Value *TripCount, Value *VectorTripCount, Value *CanonicalIVStartValue, VPTransformState &State)
Prepare the plan for execution, setting up the required live-in values.
Definition: VPlan.cpp:725
VPBasicBlock * getEntry()
Definition: VPlan.h:2575
void addLiveOut(PHINode *PN, VPValue *V)
Definition: VPlan.cpp:923
VPBasicBlock * getPreheader()
Definition: VPlan.h:2715
VPValue * getVPValueOrAddLiveIn(Value *V)
Gets the VPValue for V or adds a new live-in (if none exists yet) for V.
Definition: VPlan.h:2644
VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
Definition: VPlan.h:2677
static VPlanPtr createInitialVPlan(const SCEV *TripCount, ScalarEvolution &PSE)
Create initial VPlan skeleton, having an "entry" VPBasicBlock (wrapping original scalar pre-header) w...
Definition: VPlan.cpp:711
void addSCEVExpansion(const SCEV *S, VPValue *V)
Definition: VPlan.h:2709
LLVM_DUMP_METHOD void dump() const
Dump the plan to stderr (for debugging).
Definition: VPlan.cpp:920
void execute(VPTransformState *State)
Generate the IR code for this VPlan.
Definition: VPlan.cpp:766
void print(raw_ostream &O) const
Print this VPlan to O.
Definition: VPlan.cpp:847
VPValue * getSCEVExpansion(const SCEV *S) const
Definition: VPlan.h:2705
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:683
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:172
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:169
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:642
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
Definition: CallingConv.h:76
std::string EscapeString(const std::string &Label)
Definition: GraphWriter.cpp:55
@ SS
Definition: X86.h:207
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr, ScalarEvolution &SE)
Get or create a VPValue that corresponds to the expansion of Expr.
Definition: VPlan.cpp:1251
bool isUniformAfterVectorization(VPValue *VPV)
Returns true if VPV is uniform after vectorization.
Definition: VPlan.h:3030
bool onlyFirstLaneUsed(VPValue *Def)
Returns true if only the first lane of Def is used.
Definition: VPlan.cpp:1246
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition: STLExtras.h:329
Interval::succ_iterator succ_end(Interval *I)
Definition: Interval.h:102
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1726
auto successors(const MachineBasicBlock *BB)
Value * getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF)
Return the runtime value for VF.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:99
void interleaveComma(const Container &c, StreamT &os, UnaryFunctor each_fn)
Definition: STLExtras.h:2134
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:665
iterator_range< df_iterator< VPBlockShallowTraversalWrapper< VPBlockBase * > > > vp_depth_first_shallow(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in depth-first order.
Definition: VPlanCFG.h:214
Instruction * propagateMetadata(Instruction *I, ArrayRef< Value * > VL)
Specifically, let Kinds = [MD_tbaa, MD_alias_scope, MD_noalias, MD_fpmath, MD_nontemporal,...
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
cl::opt< bool > EnableFSDiscriminator
cl::opt< bool > EnableVPlanNativePath("enable-vplan-native-path", cl::Hidden, cl::desc("Enable VPlan-native vectorization path with " "support for outer loop vectorization."))
Definition: VPlan.cpp:51
std::unique_ptr< VPlan > VPlanPtr
Definition: VPlan.h:132
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
Definition: SmallVector.h:1303
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:292
BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
VPIteration represents a single point in the iteration space of the output (vectorized and/or unrolle...
Definition: VPlan.h:217
Hold state information used when constructing the CFG of the output IR, traversing the VPBasicBlocks ...
Definition: VPlan.h:357
BasicBlock * PrevBB
The previous IR BasicBlock created or used.
Definition: VPlan.h:363
SmallDenseMap< VPBasicBlock *, BasicBlock * > VPBB2IRBB
A mapping of each VPBasicBlock to the corresponding BasicBlock.
Definition: VPlan.h:371
VPBasicBlock * PrevVPBB
The previous VPBasicBlock visited. Initially set to null.
Definition: VPlan.h:359
BasicBlock * ExitBB
The last IR BasicBlock in the output IR.
Definition: VPlan.h:367
BasicBlock * getPreheaderBBFor(VPRecipeBase *R)
Returns the BasicBlock* mapped to the pre-header of the loop region containing R.
Definition: VPlan.cpp:329
DenseMap< VPValue *, ScalarsPerPartValuesTy > PerPartScalars
Definition: VPlan.h:259
DenseMap< VPValue *, PerPartValuesTy > PerPartOutput
Definition: VPlan.h:256
VPTransformState holds information passed down when "executing" a VPlan, needed for generating the ou...
Definition: VPlan.h:234
VPValue2ValueTy VPValue2Value
Definition: VPlan.h:389
LoopInfo * LI
Hold a pointer to LoopInfo to register new basic blocks in the loop.
Definition: VPlan.h:381
void addMetadata(Instruction *To, Instruction *From)
Add metadata from one instruction to another.
Definition: VPlan.cpp:342
Value * get(VPValue *Def, unsigned Part)
Get the generated Value for a given VPValue and a given Part.
Definition: VPlan.cpp:237
struct llvm::VPTransformState::DataState Data
struct llvm::VPTransformState::CFGState CFG
LoopVersioning * LVer
LoopVersioning.
Definition: VPlan.h:408
void addNewMetadata(Instruction *To, const Instruction *Orig)
Add additional metadata to To that was not present on Orig.
Definition: VPlan.cpp:334
void packScalarIntoVectorValue(VPValue *Def, const VPIteration &Instance)
Construct the vector value of a scalarized value V one lane at a time.
Definition: VPlan.cpp:383
std::optional< VPIteration > Instance
Hold the indices to generate specific scalar instructions.
Definition: VPlan.h:248
IRBuilderBase & Builder
Hold a reference to the IRBuilder used to generate output IR code.
Definition: VPlan.h:387
DominatorTree * DT
Hold a pointer to Dominator Tree to register new basic blocks in the loop.
Definition: VPlan.h:384
bool hasScalarValue(VPValue *Def, VPIteration Instance)
Definition: VPlan.h:278
VPlan * Plan
Pointer to the VPlan code is generated for.
Definition: VPlan.h:398
bool hasVectorValue(VPValue *Def, unsigned Part)
Definition: VPlan.h:272
ElementCount VF
The chosen Vectorization and Unroll Factors of the loop being vectorized.
Definition: VPlan.h:242
Loop * CurrentVectorLoop
The loop object for the current parent region, or nullptr.
Definition: VPlan.h:401
void setDebugLocFrom(DebugLoc DL)
Set the debug location in the builder using the debug location DL.
Definition: VPlan.cpp:362
void set(VPValue *Def, Value *V, unsigned Part)
Set the generated Value for a given VPValue and a given Part.
Definition: VPlan.h:289
void print(raw_ostream &O) const
Definition: VPlan.cpp:1091