16#define DEBUG_TYPE "vplan"
20 for (
unsigned I = 1, E = R->getNumIncomingValues();
I != E; ++
I) {
21 VPValue *Inc = R->getIncomingValue(
I);
23 "different types inferred for different incoming values");
24 CachedTypes[Inc] = ResTy;
32 auto SetResultTyFromOp = [
this,
R]() {
34 for (
unsigned Op = 1;
Op !=
R->getNumOperands(); ++
Op) {
37 "different types inferred for different operands");
38 CachedTypes[OtherV] = ResTy;
43 unsigned Opcode =
R->getOpcode();
45 return SetResultTyFromOp();
48 case Instruction::Select: {
52 "different types inferred for different operands");
53 CachedTypes[OtherV] = ResTy;
56 case Instruction::ICmp:
59 return SetResultTyFromOp();
62 if (
auto *VecTy = dyn_cast<VectorType>(
BaseTy))
63 return VecTy->getElementType();
76 dbgs() <<
"LV: Found unhandled opcode for: ";
77 R->getVPSingleValue()->dump();
83 unsigned Opcode =
R->getOpcode();
85 case Instruction::ICmp:
86 case Instruction::FCmp:
88 case Instruction::UDiv:
89 case Instruction::SDiv:
90 case Instruction::SRem:
91 case Instruction::URem:
92 case Instruction::Add:
93 case Instruction::FAdd:
94 case Instruction::Sub:
95 case Instruction::FSub:
96 case Instruction::Mul:
97 case Instruction::FMul:
98 case Instruction::FDiv:
99 case Instruction::FRem:
100 case Instruction::Shl:
101 case Instruction::LShr:
102 case Instruction::AShr:
103 case Instruction::And:
104 case Instruction::Or:
105 case Instruction::Xor: {
108 "types for both operands must match for binary op");
109 CachedTypes[
R->getOperand(1)] = ResTy;
112 case Instruction::FNeg:
113 case Instruction::Freeze:
121 dbgs() <<
"LV: Found unhandled opcode for: ";
122 R->getVPSingleValue()->dump();
128 auto &CI = *cast<CallInst>(
R->getUnderlyingInstr());
133 assert((isa<VPWidenLoadRecipe>(R) || isa<VPWidenLoadEVLRecipe>(R)) &&
134 "Store recipes should not define any values");
135 return cast<LoadInst>(&
R->getIngredient())->getType();
142 "different types inferred for different operands");
143 CachedTypes[OtherV] = ResTy;
148 switch (
R->getUnderlyingInstr()->getOpcode()) {
149 case Instruction::Call: {
150 unsigned CallIdx =
R->getNumOperands() - (
R->isPredicated() ? 2 : 1);
151 return cast<Function>(
R->getOperand(CallIdx)->getLiveInIRValue())
154 case Instruction::UDiv:
155 case Instruction::SDiv:
156 case Instruction::SRem:
157 case Instruction::URem:
158 case Instruction::Add:
159 case Instruction::FAdd:
160 case Instruction::Sub:
161 case Instruction::FSub:
162 case Instruction::Mul:
163 case Instruction::FMul:
164 case Instruction::FDiv:
165 case Instruction::FRem:
166 case Instruction::Shl:
167 case Instruction::LShr:
168 case Instruction::AShr:
169 case Instruction::And:
170 case Instruction::Or:
171 case Instruction::Xor: {
174 "inferred types for operands of binary op don't match");
175 CachedTypes[
R->getOperand(1)] = ResTy;
178 case Instruction::Select: {
181 "inferred types for operands of select op don't match");
182 CachedTypes[
R->getOperand(2)] = ResTy;
185 case Instruction::ICmp:
186 case Instruction::FCmp:
188 case Instruction::AddrSpaceCast:
189 case Instruction::Alloca:
190 case Instruction::BitCast:
191 case Instruction::Trunc:
192 case Instruction::SExt:
193 case Instruction::ZExt:
194 case Instruction::FPExt:
195 case Instruction::FPTrunc:
196 case Instruction::ExtractValue:
197 case Instruction::SIToFP:
198 case Instruction::UIToFP:
199 case Instruction::FPToSI:
200 case Instruction::FPToUI:
201 case Instruction::PtrToInt:
202 case Instruction::IntToPtr:
203 return R->getUnderlyingInstr()->getType();
204 case Instruction::Freeze:
205 case Instruction::FNeg:
206 case Instruction::GetElementPtr:
208 case Instruction::Load:
209 return cast<LoadInst>(
R->getUnderlyingInstr())->getType();
210 case Instruction::Store:
220 dbgs() <<
"LV: Found unhandled opcode for: ";
221 R->getVPSingleValue()->dump();
227 if (
Type *CachedTy = CachedTypes.lookup(V))
231 if (
auto *IRValue = V->getLiveInIRValue())
232 return IRValue->getType();
235 return CanonicalIVTy;
249 .Case<VPWidenIntOrFpInductionRecipe, VPDerivedIVRecipe>(
250 [](
const auto *R) {
return R->getScalarType(); })
257 [
this](
const auto *R) {
return inferScalarTypeForRecipe(R); })
260 return V->getUnderlyingValue()->getType();
262 .Case<VPWidenCastRecipe>(
264 .Case<VPScalarCastRecipe>(
267 return R->getSCEV()->getType();
270 assert(ResultTy &&
"could not infer type for the given VPValue");
271 CachedTypes[V] = ResultTy;
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.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
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 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.
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.
A recipe for widening Call instructions.
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 copy of vector type its ingredient.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
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.