18#define DEBUG_TYPE "vplan"
22 for (
unsigned I = 1, E = R->getNumIncomingValues();
I != E; ++
I) {
23 VPValue *Inc = R->getIncomingValue(
I);
25 "different types inferred for different incoming values");
26 CachedTypes[Inc] = ResTy;
34 auto SetResultTyFromOp = [
this,
R]() {
36 for (
unsigned Op = 1;
Op !=
R->getNumOperands(); ++
Op) {
39 "different types inferred for different operands");
40 CachedTypes[OtherV] = ResTy;
45 unsigned Opcode =
R->getOpcode();
47 return SetResultTyFromOp();
50 case Instruction::Select: {
54 "different types inferred for different operands");
55 CachedTypes[OtherV] = ResTy;
58 case Instruction::ICmp:
63 return SetResultTyFromOp();
66 if (
auto *VecTy = dyn_cast<VectorType>(
BaseTy))
67 return VecTy->getElementType();
83 dbgs() <<
"LV: Found unhandled opcode for: ";
84 R->getVPSingleValue()->dump();
90 unsigned Opcode =
R->getOpcode();
92 case Instruction::ICmp:
93 case Instruction::FCmp:
95 case Instruction::UDiv:
96 case Instruction::SDiv:
97 case Instruction::SRem:
98 case Instruction::URem:
99 case Instruction::Add:
100 case Instruction::FAdd:
101 case Instruction::Sub:
102 case Instruction::FSub:
103 case Instruction::Mul:
104 case Instruction::FMul:
105 case Instruction::FDiv:
106 case Instruction::FRem:
107 case Instruction::Shl:
108 case Instruction::LShr:
109 case Instruction::AShr:
110 case Instruction::And:
111 case Instruction::Or:
112 case Instruction::Xor: {
115 "types for both operands must match for binary op");
116 CachedTypes[
R->getOperand(1)] = ResTy;
119 case Instruction::FNeg:
120 case Instruction::Freeze:
128 dbgs() <<
"LV: Found unhandled opcode for: ";
129 R->getVPSingleValue()->dump();
135 auto &CI = *cast<CallInst>(
R->getUnderlyingInstr());
140 assert((isa<VPWidenLoadRecipe>(R) || isa<VPWidenLoadEVLRecipe>(R)) &&
141 "Store recipes should not define any values");
142 return cast<LoadInst>(&
R->getIngredient())->getType();
149 "different types inferred for different operands");
150 CachedTypes[OtherV] = ResTy;
155 switch (
R->getUnderlyingInstr()->getOpcode()) {
156 case Instruction::Call: {
157 unsigned CallIdx =
R->getNumOperands() - (
R->isPredicated() ? 2 : 1);
158 return cast<Function>(
R->getOperand(CallIdx)->getLiveInIRValue())
161 case Instruction::UDiv:
162 case Instruction::SDiv:
163 case Instruction::SRem:
164 case Instruction::URem:
165 case Instruction::Add:
166 case Instruction::FAdd:
167 case Instruction::Sub:
168 case Instruction::FSub:
169 case Instruction::Mul:
170 case Instruction::FMul:
171 case Instruction::FDiv:
172 case Instruction::FRem:
173 case Instruction::Shl:
174 case Instruction::LShr:
175 case Instruction::AShr:
176 case Instruction::And:
177 case Instruction::Or:
178 case Instruction::Xor: {
181 "inferred types for operands of binary op don't match");
182 CachedTypes[
R->getOperand(1)] = ResTy;
185 case Instruction::Select: {
188 "inferred types for operands of select op don't match");
189 CachedTypes[
R->getOperand(2)] = ResTy;
192 case Instruction::ICmp:
193 case Instruction::FCmp:
195 case Instruction::AddrSpaceCast:
196 case Instruction::Alloca:
197 case Instruction::BitCast:
198 case Instruction::Trunc:
199 case Instruction::SExt:
200 case Instruction::ZExt:
201 case Instruction::FPExt:
202 case Instruction::FPTrunc:
203 case Instruction::ExtractValue:
204 case Instruction::SIToFP:
205 case Instruction::UIToFP:
206 case Instruction::FPToSI:
207 case Instruction::FPToUI:
208 case Instruction::PtrToInt:
209 case Instruction::IntToPtr:
210 return R->getUnderlyingInstr()->getType();
211 case Instruction::Freeze:
212 case Instruction::FNeg:
213 case Instruction::GetElementPtr:
215 case Instruction::Load:
216 return cast<LoadInst>(
R->getUnderlyingInstr())->getType();
217 case Instruction::Store:
227 dbgs() <<
"LV: Found unhandled opcode for: ";
228 R->getVPSingleValue()->dump();
234 if (
Type *CachedTy = CachedTypes.lookup(V))
238 if (
auto *IRValue = V->getLiveInIRValue())
239 return IRValue->getType();
242 return CanonicalIVTy;
250 [
this](
const auto *R) {
257 .Case<VPWidenIntOrFpInductionRecipe, VPDerivedIVRecipe>(
258 [](
const auto *R) {
return R->getScalarType(); })
266 [
this](
const auto *R) {
return inferScalarTypeForRecipe(R); })
269 return V->getUnderlyingValue()->getType();
271 .Case<VPWidenCastRecipe>(
273 .Case<VPScalarCastRecipe>(
276 return R->getSCEV()->getType();
278 .Case<VPReductionRecipe>([
this](
const auto *R) {
282 assert(ResultTy &&
"could not infer type for the given VPValue");
283 CachedTypes[V] = ResultTy;
291 for (
VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
294 auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
295 if (!RepR || !
match(RepR->getUnderlyingInstr(),
296 PatternMatch::m_Intrinsic<Intrinsic::assume>()))
306 while (!Worklist.
empty()) {
309 auto *OpR =
Op->getDefiningRecipe();
310 if (!OpR || OpR->mayHaveSideEffects() || EphRecipes.
contains(OpR))
313 auto *UR = dyn_cast<VPRecipeBase>(U);
314 return !UR || !EphRecipes.contains(UR);
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the TypeSwitch template, which mimics a switch() statement whose cases are type ...
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.
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 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.
Canonical scalar induction phi of the vector loop.
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 ...
const VPBlockBase * getEntry() const
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
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...
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 for all parts.
A recipe for widening Call instructions.
A Recipe for widening the canonical induction variable of the vector loop.
VPWidenCastRecipe is a recipe to create vector cast instructions.
A recipe for handling GEP instructions.
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.