13#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
14#define LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
43#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
55 template <
bool EnableVerify =
true,
typename PassTy,
typename... ArgsTy>
58#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
65 std::string NumberedPassName;
69 Instance = ++PassCounter[{Fn,
PassName}];
71 NumberedPassName = Instance == 1
76 auto PrintPlan = [&](
StringRef BeforeOrAfterStr) {
77 dbgs() <<
"VPlan for loop in '" << Fn->
getName() <<
"' "
78 << BeforeOrAfterStr <<
" " << NumberedPassName <<
'\n';
82 dbgs() << Plan <<
'\n';
86 return (ListOpt.getNumOccurrences() > 0 &&
97#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
109 return std::forward<PassTy>(
Pass)(Plan, std::forward<ArgsTy>(Args)...);
111#define RUN_VPLAN_PASS(PASS, ...) \
112 llvm::VPlanTransforms::runPass(#PASS, PASS, __VA_ARGS__)
113#define RUN_VPLAN_PASS_NO_VERIFY(PASS, ...) \
114 llvm::VPlanTransforms::runPass<false>(#PASS, PASS, __VA_ARGS__)
159 PredicatedScalarEvolution &PSE, LoopVersioning *LVer =
nullptr,
160 function_ref<
const BranchProbabilityInfo &()> GetBPI =
nullptr);
174 VPlan &Plan, PredicatedScalarEvolution &PSE,
Loop &OrigLoop,
175 OptimizationRemarkEmitter *ORE,
const VPDominatorTree &VPDT,
176 const MapVector<PHINode *, InductionDescriptor> &Inductions,
177 const MapVector<PHINode *, RecurrenceDescriptor> &
Reductions,
178 const SmallPtrSetImpl<const PHINode *> &FixedOrderRecurrences,
179 const SmallPtrSetImpl<PHINode *> &InLoopReductions,
bool AllowReordering);
188 bool OptForSize,
unsigned SCEVCheckThreshold,
189 OptimizationRemarkEmitter *ORE,
Loop *TheLoop);
203 VPlan &Plan, ElementCount VF,
unsigned UF,
204 ElementCount MinProfitableTripCount,
bool RequiresScalarEpilogue,
206 DebugLoc DL, PredicatedScalarEvolution &PSE, VPBasicBlock *CheckBlock);
212 bool RequiresScalarEpilogue,
Loop *OrigLoop,
219 VPlan &Plan, VPValue *MainVectorTripCount,
bool RequiresScalarEpilogue,
220 ElementCount EpilogueVF,
unsigned MainLoopStep,
unsigned EpilogueLoopStep,
221 ScalarEvolution &SE);
231 VPBasicBlock *CheckBlock,
232 bool AddBranchWeights);
234 bool AddBranchWeights);
240 bool AddBranchWeights);
248 VPIRBasicBlock *EnteredFrom);
255 VPlan &Plan,
const TargetLibraryInfo &TLI, PredicatedScalarEvolution &PSE,
263 OptimizationRemarkEmitter *ORE,
283 static void unrollByUF(VPlan &Plan,
unsigned UF);
296 PredicatedScalarEvolution &PSE);
301 PredicatedScalarEvolution &PSE);
322 bool UseActiveLaneMaskForControlFlow);
328 const MapVector<Instruction *, uint64_t> &MinBWs);
333 PredicatedScalarEvolution &PSE);
338 PredicatedScalarEvolution &PSE,
340 const VPDominatorTree &VPDT);
357 const std::optional<unsigned> &MaxEVLSafeElements);
373 const SmallPtrSetImpl<
const InterleaveGroup<Instruction> *>
375 const bool &EpilogueAllowed);
381 PredicatedScalarEvolution &PSE,
Loop &L,
382 VPCostContext &Ctx, VFRange &
Range);
392 PredicatedScalarEvolution &PSE,
394 AssumptionCache *AC);
408 Loop *TheLoop, PredicatedScalarEvolution &PSE,
409 DominatorTree &DT, AssumptionCache *AC,
460 static void cse(VPlan &Plan);
466 PredicatedScalarEvolution &PSE,
488 const TargetTransformInfo &
TTI);
495 PredicatedScalarEvolution &PSE);
502 VPlan &Plan, VPBasicBlock *VectorPHVPBB,
bool TailByMasking,
503 bool RequiresScalarEpilogue, VPValue *Step,
504 std::optional<uint64_t> MaxRuntimeStep = std::nullopt);
509 VPBasicBlock *VectorPH);
527 VPBasicBlock *AliasCheckVPBB,
544 static DenseMap<const SCEV *, Value *>
expandSCEVs(VPlan &Plan,
545 ScalarEvolution &SE);
559 static std::unique_ptr<VPlan>
606 const TargetTransformInfo &
TTI,
608 ElementCount VF,
unsigned UF);
614 std::optional<unsigned> VScaleForTuning);
629 PredicatedScalarEvolution &PSE,
Loop &L);
641 VPRecipeBuilder &RecipeBuilder,
642 VPCostContext &CostCtx);
654 VPRecipeBuilder &RecipeBuilder,
655 VPCostContext &CostCtx);
663 const TargetTransformInfo &
TTI,
664 PredicatedScalarEvolution &PSE);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ABI_FOR_TEST
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static constexpr uint32_t MinItersBypassWeights[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
const SmallVectorImpl< MachineOperand > & Cond
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
This file declares the class VPlanVerifier, which contains utility functions to check the consistency...
This file contains the declarations of the Vectorization Plan base classes:
static const char PassName[]
const Function * getParent() const
Return the enclosing method, or null if none.
Analysis providing branch probability information.
A struct for saving information about induction variables.
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't ove...
Represents a single loop in the control flow graph.
Pass interface - Implemented by all 'passes'.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
LLVM_ABI bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
The main scalar evolution driver.
Represent a constant reference to a string, i.e.
Provides information about what library functions are available for the current target.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
BasicBlock * getIRBasicBlock() const
Helper class to create VPRecipies from IR instructions.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print this VPRegionBlock to O (recursively), prefixing all lines with Indent.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI_FOR_TEST cl::opt< bool > VerifyEachVPlan
LLVM_ABI_FOR_TEST cl::opt< bool > VPlanPrintAfterAll
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
DenseMap< Value *, const SCEVUnknown * > SymbolicStrideMap
Maps a pointer to its symbolic (non-constant) stride.
UncountableExitStyle
Different methods of handling early exits.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI_FOR_TEST cl::list< std::string > VPlanPrintAfterPasses
LLVM_ABI_FOR_TEST cl::list< std::string > VPlanPrintBeforePasses
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI_FOR_TEST cl::opt< bool > VPlanPrintBeforeAll
LLVM_ABI_FOR_TEST bool verifyVPlanIsValid(const VPlan &Plan)
Verify invariants for general VPlans.
LLVM_ABI_FOR_TEST cl::opt< bool > VPlanPrintVectorRegionScope
A range of powers-of-2 vectorization factors with fixed start and adjustable end.