13#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
14#define LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
44#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
54 template <
bool EnableVerify =
true,
typename PassTy,
typename... ArgsTy>
58#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
67 <<
"VPlan for loop in '"
73 dbgs() << Plan <<
'\n';
82 return std::forward<PassTy>(
Pass)(Plan, std::forward<ArgsTy>(Args)...);
84#define RUN_VPLAN_PASS(PASS, ...) \
85 llvm::VPlanTransforms::runPass(#PASS, PASS, __VA_ARGS__)
86#define RUN_VPLAN_PASS_NO_VERIFY(PASS, ...) \
87 llvm::VPlanTransforms::runPass<false>(#PASS, PASS, __VA_ARGS__)
131 buildVPlan0(Loop *TheLoop, LoopInfo &LI, Type *InductionTy,
132 PredicatedScalarEvolution &PSE, LoopVersioning *LVer =
nullptr);
142 VPlan &Plan, PredicatedScalarEvolution &PSE, Loop &OrigLoop,
143 const VPDominatorTree &VPDT,
144 const MapVector<PHINode *, InductionDescriptor> &Inductions,
145 const MapVector<PHINode *, RecurrenceDescriptor> &
Reductions,
146 const SmallPtrSetImpl<const PHINode *> &FixedOrderRecurrences,
147 const SmallPtrSetImpl<PHINode *> &InLoopReductions,
bool AllowReordering);
156 bool OptForSize,
unsigned SCEVCheckThreshold,
157 OptimizationRemarkEmitter *ORE, Loop *TheLoop);
170 PredicatedScalarEvolution &PSE, DominatorTree &DT,
171 AssumptionCache *AC);
180 VPlan &Plan, ElementCount VF,
unsigned UF,
181 ElementCount MinProfitableTripCount,
bool RequiresScalarEpilogue,
183 DebugLoc DL, PredicatedScalarEvolution &PSE, VPBasicBlock *CheckBlock);
189 bool RequiresScalarEpilogue, Loop *OrigLoop,
196 VPlan &Plan, Value *VectorTripCount,
bool RequiresScalarEpilogue,
197 ElementCount EpilogueVF,
unsigned EpilogueUF,
unsigned MainLoopStep,
198 unsigned EpilogueLoopStep, ScalarEvolution &SE);
210 VPBasicBlock *CheckBlock,
211 bool AddBranchWeights);
213 bool AddBranchWeights);
220 const TargetLibraryInfo &TLI);
227 OptimizationRemarkEmitter *ORE,
247 static void unrollByUF(VPlan &Plan,
unsigned UF);
260 PredicatedScalarEvolution &PSE);
265 PredicatedScalarEvolution &PSE);
287 bool UseActiveLaneMaskForControlFlow);
293 const MapVector<Instruction *, uint64_t> &MinBWs);
299 const DenseMap<Value *, const SCEV *> &StridesMap,
300 const VPDominatorTree &VPDT);
317 const std::optional<unsigned> &MaxEVLSafeElements);
333 const SmallPtrSetImpl<
const InterleaveGroup<Instruction> *>
335 const bool &EpilogueAllowed);
341 PredicatedScalarEvolution &PSE, Loop &L,
342 VPCostContext &Ctx, VFRange &
Range);
352 VPlan &Plan, VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB,
353 VPBasicBlock *MiddleVPBB, Loop *TheLoop, PredicatedScalarEvolution &PSE,
398 static void cse(VPlan &Plan);
404 PredicatedScalarEvolution &PSE,
428 PredicatedScalarEvolution &PSE);
435 VPlan &Plan, VPBasicBlock *VectorPHVPBB,
bool TailByMasking,
436 bool RequiresScalarEpilogue, VPValue *Step,
437 std::optional<uint64_t> MaxRuntimeStep = std::nullopt);
442 VPBasicBlock *VectorPH);
460 VPBasicBlock *AliasCheckVPBB,
478 static DenseMap<const SCEV *, Value *>
expandSCEVs(VPlan &Plan,
479 ScalarEvolution &SE);
493 static std::unique_ptr<VPlan>
539 VPlan &Plan, ScalarEvolution &SE,
const TargetTransformInfo &
TTI,
541 unsigned UF,
const SmallPtrSetImpl<const Value *> &ValuesToIgnore);
547 std::optional<unsigned> VScaleForTuning);
560 PredicatedScalarEvolution &PSE, Loop &L);
571 VPRecipeBuilder &RecipeBuilder);
581 VPRecipeBuilder &RecipeBuilder,
582 VPCostContext &CostCtx);
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 make_scope_exit function, which executes user-defined cleanup logic at scope ex...
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.
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.
VPlan-based builder utility analogous to IRBuilder.
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.
LLVM_ABI_FOR_TEST cl::opt< bool > EnableWideActiveLaneMask
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
ArrayRef(const T &OneElt) -> ArrayRef< T >
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.