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:
65 auto *PhiR = cast<VPReductionPHIRecipe>(
R->getOperand(0));
66 auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue());
67 return OrigPhi->getType();
74 return SetResultTyFromOp();
77 if (
auto *VecTy = dyn_cast<VectorType>(
BaseTy))
78 return VecTy->getElementType();
94 dbgs() <<
"LV: Found unhandled opcode for: ";
95 R->getVPSingleValue()->dump();
101 unsigned Opcode =
R->getOpcode();
106 "types for both operands must match for binary op");
107 CachedTypes[
R->getOperand(1)] = ResTy;
112 case Instruction::ICmp:
113 case Instruction::FCmp:
115 case Instruction::FNeg:
116 case Instruction::Freeze:
124 dbgs() <<
"LV: Found unhandled opcode for: ";
125 R->getVPSingleValue()->dump();
131 auto &CI = *cast<CallInst>(
R->getUnderlyingInstr());
136 assert((isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(R)) &&
137 "Store recipes should not define any values");
138 return cast<LoadInst>(&
R->getIngredient())->getType();
145 "different types inferred for different operands");
146 CachedTypes[OtherV] = ResTy;
151 unsigned Opcode =
R->getUnderlyingInstr()->getOpcode();
157 "inferred types for operands of binary op don't match");
158 CachedTypes[
R->getOperand(1)] = ResTy;
163 return R->getUnderlyingInstr()->getType();
166 case Instruction::Call: {
167 unsigned CallIdx =
R->getNumOperands() - (
R->isPredicated() ? 2 : 1);
168 return cast<Function>(
R->getOperand(CallIdx)->getLiveInIRValue())
171 case Instruction::Select: {
174 "inferred types for operands of select op don't match");
175 CachedTypes[
R->getOperand(2)] = ResTy;
178 case Instruction::ICmp:
179 case Instruction::FCmp:
181 case Instruction::Alloca:
182 case Instruction::ExtractValue:
183 return R->getUnderlyingInstr()->getType();
184 case Instruction::Freeze:
185 case Instruction::FNeg:
186 case Instruction::GetElementPtr:
188 case Instruction::Load:
189 return cast<LoadInst>(
R->getUnderlyingInstr())->getType();
190 case Instruction::Store:
200 dbgs() <<
"LV: Found unhandled opcode for: ";
201 R->getVPSingleValue()->dump();
207 if (
Type *CachedTy = CachedTypes.lookup(V))
211 if (
auto *IRValue = V->getLiveInIRValue())
212 return IRValue->getType();
215 return CanonicalIVTy;
230 .Case<VPWidenIntOrFpInductionRecipe, VPDerivedIVRecipe>(
231 [](
const auto *R) {
return R->getScalarType(); })
241 [
this](
const auto *R) {
return inferScalarTypeForRecipe(R); })
243 return R->getResultType();
247 return V->getUnderlyingValue()->getType();
249 .Case<VPWidenCastRecipe>(
251 .Case<VPScalarCastRecipe>(
254 return R->getSCEV()->getType();
256 .Case<VPReductionRecipe>([
this](
const auto *R) {
260 assert(ResultTy &&
"could not infer type for the given VPValue");
261 CachedTypes[V] = ResultTy;
269 for (
VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
272 auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
273 if (!RepR || !
match(RepR->getUnderlyingInstr(),
274 PatternMatch::m_Intrinsic<Intrinsic::assume>()))
284 while (!Worklist.
empty()) {
287 auto *OpR =
Op->getDefiningRecipe();
288 if (!OpR || OpR->mayHaveSideEffects() || EphRecipes.
contains(OpR))
291 auto *UR = dyn_cast<VPRecipeBase>(U);
292 return !UR || !EphRecipes.contains(UR);
301template void DomTreeBuilder::Calculate<DominatorTreeBase<VPBlockBase, false>>(
310 for (
auto &R : *
A->getParent()) {
320 if (ParentA == ParentB)
321 return LocalComesBefore(
A,
B);
325 auto *
Region = dyn_cast_or_null<VPRegionBlock>(R->getParent()->getParent());
328 Region->getNumPredecessors() == 1 &&
"Expected SESE region!");
329 assert(R->getParent()->size() == 1 &&
330 "A recipe in an original replicator region must be the only "
331 "recipe in its block");
337 "No replicate regions expected at this point");
339 "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.
@ ResumePhi
Creates a scalar phi in a leaf VPBB with a single predecessor in VPlan.
@ FirstOrderRecurrenceSplice
VPInterleaveRecipe is a recipe for transforming an interleave group of load or stores into one wide l...
A recipe for forming partial reductions.
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.