21#define DEBUG_TYPE "vplan"
25 for (
unsigned I = 1, E = R->getNumIncomingValues();
I != E; ++
I) {
26 VPValue *Inc = R->getIncomingValue(
I);
28 "different types inferred for different incoming values");
29 CachedTypes[Inc] = ResTy;
37 auto SetResultTyFromOp = [
this,
R]() {
39 for (
unsigned Op = 1;
Op !=
R->getNumOperands(); ++
Op) {
42 "different types inferred for different operands");
43 CachedTypes[OtherV] = ResTy;
48 unsigned Opcode =
R->getOpcode();
50 return SetResultTyFromOp();
53 case Instruction::Select: {
57 "different types inferred for different operands");
58 CachedTypes[OtherV] = ResTy;
61 case Instruction::ICmp:
68 return SetResultTyFromOp();
71 if (
auto *VecTy = dyn_cast<VectorType>(
BaseTy))
72 return VecTy->getElementType();
88 dbgs() <<
"LV: Found unhandled opcode for: ";
89 R->getVPSingleValue()->dump();
95 unsigned Opcode =
R->getOpcode();
100 "types for both operands must match for binary op");
101 CachedTypes[
R->getOperand(1)] = ResTy;
106 case Instruction::ICmp:
107 case Instruction::FCmp:
109 case Instruction::FNeg:
110 case Instruction::Freeze:
118 dbgs() <<
"LV: Found unhandled opcode for: ";
119 R->getVPSingleValue()->dump();
125 auto &CI = *cast<CallInst>(
R->getUnderlyingInstr());
130 assert((isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(R)) &&
131 "Store recipes should not define any values");
132 return cast<LoadInst>(&
R->getIngredient())->getType();
139 "different types inferred for different operands");
140 CachedTypes[OtherV] = ResTy;
145 unsigned Opcode =
R->getUnderlyingInstr()->getOpcode();
151 "inferred types for operands of binary op don't match");
152 CachedTypes[
R->getOperand(1)] = ResTy;
157 return R->getUnderlyingInstr()->getType();
160 case Instruction::Call: {
161 unsigned CallIdx =
R->getNumOperands() - (
R->isPredicated() ? 2 : 1);
162 return cast<Function>(
R->getOperand(CallIdx)->getLiveInIRValue())
165 case Instruction::Select: {
168 "inferred types for operands of select op don't match");
169 CachedTypes[
R->getOperand(2)] = ResTy;
172 case Instruction::ICmp:
173 case Instruction::FCmp:
175 case Instruction::Alloca:
176 case Instruction::ExtractValue:
177 return R->getUnderlyingInstr()->getType();
178 case Instruction::Freeze:
179 case Instruction::FNeg:
180 case Instruction::GetElementPtr:
182 case Instruction::Load:
183 return cast<LoadInst>(
R->getUnderlyingInstr())->getType();
184 case Instruction::Store:
194 dbgs() <<
"LV: Found unhandled opcode for: ";
195 R->getVPSingleValue()->dump();
201 if (
Type *CachedTy = CachedTypes.lookup(V))
205 if (
auto *IRValue = V->getLiveInIRValue())
206 return IRValue->getType();
209 return CanonicalIVTy;
224 .Case<VPWidenIntOrFpInductionRecipe, VPDerivedIVRecipe>(
225 [](
const auto *R) {
return R->getScalarType(); })
235 [
this](
const auto *R) {
return inferScalarTypeForRecipe(R); })
237 return R->getResultType();
241 return V->getUnderlyingValue()->getType();
243 .Case<VPWidenCastRecipe>(
245 .Case<VPScalarCastRecipe>(
248 return R->getSCEV()->getType();
250 .Case<VPReductionRecipe>([
this](
const auto *R) {
254 assert(ResultTy &&
"could not infer type for the given VPValue");
255 CachedTypes[V] = ResultTy;
263 for (
VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
266 auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
267 if (!RepR || !
match(RepR->getUnderlyingInstr(),
268 PatternMatch::m_Intrinsic<Intrinsic::assume>()))
278 while (!Worklist.
empty()) {
281 auto *OpR =
Op->getDefiningRecipe();
282 if (!OpR || OpR->mayHaveSideEffects() || EphRecipes.
contains(OpR))
285 auto *UR = dyn_cast<VPRecipeBase>(U);
286 return !UR || !EphRecipes.contains(UR);
295template void DomTreeBuilder::Calculate<DominatorTreeBase<VPBlockBase, false>>(
304 for (
auto &R : *
A->getParent()) {
314 if (ParentA == ParentB)
315 return LocalComesBefore(
A,
B);
319 auto *
Region = dyn_cast_or_null<VPRegionBlock>(R->getParent()->getParent());
322 Region->getNumPredecessors() == 1 &&
"Expected SESE region!");
323 assert(R->getParent()->size() == 1 &&
324 "A recipe in an original replicator region must be the only "
325 "recipe in its block");
331 "No replicate regions expected at this point");
333 "No replicate regions expected at this point");
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Generic dominator tree construction - this file provides routines to construct immediate dominator in...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the TypeSwitch template, which mimics a switch() statement whose cases are type ...
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
This file contains the declarations of the Vectorization Plan base classes:
This class represents an Operation in the Expression.
Implements a dense probed hash-table based set.
Core dominator tree base class.
bool properlyDominates(const DomTreeNodeBase< VPBlockBase > *A, const DomTreeNodeBase< VPBlockBase > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionalit...
TypeSwitch< T, ResultT > & Case(CallableT &&caseFn)
Add a case on the given type.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static Type * getVoidTy(LLVMContext &C)
A recipe for generating the active lane mask for the vector loop that is used to predicate the vector...
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.
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
Canonical scalar induction phi of the vector loop.
bool properlyDominates(const VPRecipeBase *A, const VPRecipeBase *B)
Returns true if A properly dominates B.
A recipe for generating the phi node for the current index of elements, adjusted in accordance with E...
Recipe to expand a SCEV expression.
This is a concrete Recipe that models a single VPlan-level instruction.
@ FirstOrderRecurrenceSplice
VPInterleaveRecipe is a recipe for transforming an interleave group of load or stores into one wide l...
VPPredInstPHIRecipe is a recipe for generating the phi nodes needed when control converges back from ...
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
A recipe for handling reduction phis.
A recipe to represent inloop reduction operations, performing a reduction on a vector operand into a ...
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
const VPBlockBase * getEntry() const
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
A recipe to compute the pointers for widened memory accesses of IndexTy in reverse order.
VPScalarCastRecipe is a recipe to create scalar cast instructions.
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
Recipe to generate a scalar PHI.
Type * inferScalarType(const VPValue *V)
Infer the type of V. Returns the scalar type of V.
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
A recipe to compute the pointers for widened memory accesses of IndexTy.
A recipe for widening Call instructions using library calls.
A Recipe for widening the canonical induction variable of the vector loop.
VPWidenCastRecipe is a recipe to create vector cast instructions.
A recipe for widening operations with vector-predication intrinsics with explicit vector length (EVL)...
A recipe for handling GEP instructions.
A recipe for widening vector intrinsics.
A common base class for widening memory operations.
A recipe for handling phis that are widened in the vector loop.
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...
VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool match(Val *V, const Pattern &P)
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< df_iterator< VPBlockDeepTraversalWrapper< VPBlockBase * > > > vp_depth_first_deep(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in depth-first order while traversing t...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void collectEphemeralRecipesForVPlan(VPlan &Plan, DenseSet< VPRecipeBase * > &EphRecipes)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DWARFExpression::Operation Op
A recipe for handling first-order recurrence phis.
A recipe for widening select instructions.