9#ifndef LLVM_TRANSFORMS_VECTORIZE_VPRECIPEBUILDER_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPRECIPEBUILDER_H
21class LoopVectorizationLegality;
22class LoopVectorizationCostModel;
23class TargetLibraryInfo;
24class TargetTransformInfo;
92 ScaledReductionExitInstrs;
147 std::optional<std::pair<PartialReductionChain, unsigned>>
158 CM(CM), PSE(PSE), Builder(Builder) {}
160 std::optional<std::pair<PartialReductionChain, unsigned>>
162 auto It = ScaledReductionExitInstrs.
find(ExitInst);
163 return It == ScaledReductionExitInstrs.
end()
165 : std::make_optional(It->second);
186 "Cannot reset recipe for instruction.");
187 Ingredient2Recipe[
I] = R;
215 "Recording this ingredients recipe was not requested");
216 assert(Ingredient2Recipe[
I] !=
nullptr &&
217 "Ingredient doesn't have a recipe");
218 return Ingredient2Recipe[
I];
236 if (
auto *
I = dyn_cast<Instruction>(V)) {
237 if (
auto *R = Ingredient2Recipe.
lookup(
I))
238 return R->getVPSingleValue();
This file defines the DenseMap class.
This file provides a LoopVectorizationPlanner class.
mir Rename Register Operands
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the PointerUnion class, which is a discriminated union of pointer types.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains the declarations of the Vectorization Plan base classes:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
This class represents a function call, abstracting a target machine's calling convention.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
LoopVectorizationCostModel - estimates the expected speedups due to vectorization.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor...
Represents a single loop in the control flow graph.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
This class represents a truncation of integer types.
A Use represents the edge between a Value definition and its users.
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
A recipe for vectorizing a phi-node as a sequence of mask-based select instructions.
VPlan-based builder utility analogous to IRBuilder.
A recipe representing a sequence of load -> update -> store as part of a histogram operation.
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
Helper class to create VPRecipies from IR instructions.
VPRecipeBase * tryToCreatePartialReduction(Instruction *Reduction, ArrayRef< VPValue * > Operands)
Create and return a partial reduction recipe for a reduction instruction along with binary operation ...
VPValue * createEdgeMask(BasicBlock *Src, BasicBlock *Dst)
A helper function that computes the predicate of the edge between SRC and DST.
VPReplicateRecipe * handleReplication(Instruction *I, VFRange &Range)
Build a VPReplicationRecipe for I.
void createSwitchEdgeMasks(SwitchInst *SI)
Create an edge mask for every destination of cases and/or default.
std::optional< std::pair< PartialReductionChain, unsigned > > getScaledReductionForInstr(const Instruction *ExitInst)
VPValue * getBlockInMask(BasicBlock *BB) const
Returns the entry mask for the block BB.
VPValue * getEdgeMask(BasicBlock *Src, BasicBlock *Dst) const
A helper that returns the previously computed predicate of the edge between SRC and DST.
iterator_range< mapped_iterator< Use *, std::function< VPValue *(Value *)> > > mapToVPValues(User::op_range Operands)
Returns a range mapping the values of the range Operands to their corresponding VPValues.
void fixHeaderPhis()
Add the incoming values from the backedge to reduction & first-order recurrence cross-iteration phis.
VPRecipeBase * tryToCreateWidenRecipe(Instruction *Instr, ArrayRef< VPValue * > Operands, VFRange &Range, VPBasicBlock *VPBB)
Create and return a widened recipe for I if one can be created within the given VF Range.
VPValue * getVPValueOrAddLiveIn(Value *V)
void createHeaderMask()
Create the mask for the vector loop header block.
void createBlockInMask(BasicBlock *BB)
A helper function that computes the predicate of the block BB, assuming that the header block of the ...
void collectScaledReductions(VFRange &Range)
Find all possible partial reductions in the loop and track all of those that are valid so recipes can...
void setRecipe(Instruction *I, VPRecipeBase *R)
Set the recipe created for given ingredient.
VPRecipeBase * getRecipe(Instruction *I)
Return the recipe created for given ingredient.
VPRecipeBuilder(VPlan &Plan, Loop *OrigLoop, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI, LoopVectorizationLegality *Legal, LoopVectorizationCostModel &CM, PredicatedScalarEvolution &PSE, VPBuilder &Builder)
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
A common base class for widening memory operations.
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
VPValue * getOrAddLiveIn(Value *V)
Gets the live-in VPValue for V or adds a new live-in (if none exists yet) for V.
LLVM Value Representation.
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
This holds details about a histogram operation – a load -> update -> store sequence where each lane i...
A chain of instructions that form a partial reduction.
Instruction * BinOp
The binary operation using the extends that is then reduced.
PartialReductionChain(Instruction *Reduction, Instruction *ExtendA, Instruction *ExtendB, Instruction *BinOp)
Instruction * Reduction
The top-level binary operation that forms the reduction to a scalar after the loop body.
Instruction * ExtendA
The extension of each of the inner binary operation's operands.
A range of powers-of-2 vectorization factors with fixed start and adjustable end.