[llvm] [VPlan] Add type in VPRecipeValue, migrate first set of recipes. (NFC) (PR #195485)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 14:40:04 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Florian Hahn (fhahn)
<details>
<summary>Changes</summary>
This patch adds a new Type field to hold the scalar type for the
VPRecipeValue. It starts the migration of an initial set of recipes to
set the scalar type and use it directly in VPTypeAnalysis, removing
special handling for those types.
ventually, VPTypeAnalysis can be retired when the migration is
complete, hopefully eliminating the need for type related caching, which
can lead to subtle invalidation errors.
To help the transition, a temporary getScalarTypeOrInfer has been added,
which returns the scalar type set in the VPValue for already migrated
recipes or falls back o type inferrence otherwise.
VPlanVerifier has been extended verify the set scalar type where
possible.
Tracking the type directly means a few places that change the type will
need to be updated to create a new replacement recipe with correct
types.
Depends on https://github.com/llvm/llvm-project/pull/195483
---
Patch is 33.99 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/195485.diff
8 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlan.cpp (+35-10)
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+65-43)
- (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp (+11-33)
- (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.h (-4)
- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+16-2)
- (modified) llvm/lib/Transforms/Vectorize/VPlanValue.h (+65-15)
- (modified) llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp (+56)
- (modified) llvm/unittests/Transforms/Vectorize/VPlanTest.cpp (+4-7)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 91fa4c57e5bf9..6834d4e86e2dd 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -122,17 +122,22 @@ void VPRecipeBase::dump() const {
#endif
#if !defined(NDEBUG)
-bool VPRecipeValue::isDefinedBy(const VPDef *D) const { return Def == D; }
+bool VPRecipeValue::isDefinedBy(const VPDef *D) const {
+ return getDefiningRecipe() == D;
+}
#endif
VPRecipeBase *VPValue::getDefiningRecipe() {
auto *DefValue = dyn_cast<VPRecipeValue>(this);
- return DefValue ? DefValue->Def : nullptr;
+ if (!DefValue)
+ return nullptr;
+ if (auto *SV = dyn_cast<VPStandaloneRecipeValue>(DefValue))
+ return SV->getDef();
+ return static_cast<VPSingleDefRecipe *>(DefValue);
}
const VPRecipeBase *VPValue::getDefiningRecipe() const {
- auto *DefValue = dyn_cast<VPRecipeValue>(this);
- return DefValue ? DefValue->Def : nullptr;
+ return const_cast<VPValue *>(this)->getDefiningRecipe();
}
Value *VPValue::getLiveInIRValue() const {
@@ -141,15 +146,35 @@ Value *VPValue::getLiveInIRValue() const {
Type *VPIRValue::getType() const { return getUnderlyingValue()->getType(); }
-VPRecipeValue::VPRecipeValue(VPRecipeBase *Def, Value *UV)
- : VPValue(VPVRecipeValueSC, UV), Def(Def) {
- assert(Def && "VPRecipeValue requires a defining recipe");
+Type *VPValue::getScalarType() const {
+ switch (getVPValueID()) {
+ case VPVIRValueSC:
+ return getUnderlyingValue()->getType();
+ case VPRegionValueSC:
+ return cast<VPRegionValue>(this)->getType();
+ case VPVStandaloneRecipeValueSC:
+ case VPVSingleDefValueSC:
+ return cast<VPRecipeValue>(this)->getScalarType();
+ }
+ llvm_unreachable("Unhandled VPValue subclass");
+}
+
+VPSingleDefValue::VPSingleDefValue(VPSingleDefRecipe *Def, Value *UV, Type *Ty)
+ : VPRecipeValue(VPVSingleDefValueSC, UV, Ty) {
+ assert(Def && "VPSingleDefValue requires a defining recipe");
+ Def->addDefinedValue(this);
+}
+
+VPRecipeValue::~VPRecipeValue() = default;
+
+VPStandaloneRecipeValue::VPStandaloneRecipeValue(VPRecipeBase *Def, Value *UV,
+ Type *Ty)
+ : VPRecipeValue(VPVStandaloneRecipeValueSC, UV, Ty), Def(Def) {
+ assert(Def && "VPStandaloneRecipeValue requires a defining recipe");
Def->addDefinedValue(this);
}
-VPRecipeValue::~VPRecipeValue() {
- assert(Users.empty() &&
- "trying to delete a VPRecipeValue with remaining users");
+VPStandaloneRecipeValue::~VPStandaloneRecipeValue() {
Def->removeDefinedValue(this);
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 592d83af2295f..3245ed86a2852 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -599,18 +599,29 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
return R->getVPRecipeID() == VPRecipeID; \
}
+/// Return the scalar type of \p V. If \p V's scalar type has not been set
+/// (e.g. the defining recipe has not yet been migrated), fall back to
+/// VPTypeAnalysis using the plan of the defining recipe.
+LLVM_ABI Type *getScalarTypeOrInfer(VPValue *V);
+
/// VPSingleDef is a base class for recipes for modeling a sequence of one or
/// more output IR that define a single result VPValue.
-/// Note that VPRecipeBase must be inherited from before VPValue.
-class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue {
+class VPSingleDefRecipe : public VPRecipeBase, public VPSingleDefValue {
public:
VPSingleDefRecipe(const unsigned char SC, ArrayRef<VPValue *> Operands,
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeBase(SC, Operands, DL), VPRecipeValue(this) {}
+ : VPRecipeBase(SC, Operands, DL), VPSingleDefValue(this) {}
VPSingleDefRecipe(const unsigned char SC, ArrayRef<VPValue *> Operands,
Value *UV, DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeBase(SC, Operands, DL), VPRecipeValue(this, UV) {}
+ : VPRecipeBase(SC, Operands, DL), VPSingleDefValue(this, UV) {}
+
+ VPSingleDefRecipe(const unsigned char SC, ArrayRef<VPValue *> Operands,
+ Type *Ty, Value *UV = nullptr,
+ DebugLoc DL = DebugLoc::getUnknown())
+ : VPRecipeBase(SC, Operands, DL), VPSingleDefValue(this, UV, Ty) {}
+
+ ~VPSingleDefRecipe() override { removeDefinedValue(this); }
static inline bool classof(const VPRecipeBase *R) {
switch (R->getVPRecipeID()) {
@@ -1112,6 +1123,12 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags {
DebugLoc DL = DebugLoc::getUnknown())
: VPSingleDefRecipe(SC, Operands, DL), VPIRFlags(Flags) {}
+ VPRecipeWithIRFlags(const unsigned char SC, ArrayRef<VPValue *> Operands,
+ Type *ResultTy, const VPIRFlags &Flags,
+ DebugLoc DL = DebugLoc::getUnknown())
+ : VPSingleDefRecipe(SC, Operands, ResultTy, /*UV=*/nullptr, DL),
+ VPIRFlags(Flags) {}
+
static inline bool classof(const VPRecipeBase *R) {
return R->getVPRecipeID() == VPRecipeBase::VPBlendSC ||
R->getVPRecipeID() == VPRecipeBase::VPInstructionSC ||
@@ -1833,16 +1850,14 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
/// Cast instruction opcode.
Instruction::CastOps Opcode;
- /// Result type for the cast.
- Type *ResultTy;
-
public:
VPWidenCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy,
CastInst *CI = nullptr, const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCastSC, Op, Flags, DL),
- VPIRMetadata(Metadata), Opcode(Opcode), ResultTy(ResultTy) {
+ : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCastSC, Op, ResultTy, Flags,
+ DL),
+ VPIRMetadata(Metadata), Opcode(Opcode) {
assert(flagsValidForOpcode(Opcode) &&
"Set flags not supported for the provided opcode");
assert(hasRequiredFlagsForOpcode(Opcode) &&
@@ -1853,7 +1868,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
~VPWidenCastRecipe() override = default;
VPWidenCastRecipe *clone() override {
- return new VPWidenCastRecipe(Opcode, getOperand(0), ResultTy,
+ return new VPWidenCastRecipe(Opcode, getOperand(0), getScalarType(),
cast_or_null<CastInst>(getUnderlyingValue()),
*this, *this, getDebugLoc());
}
@@ -1870,7 +1885,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
Instruction::CastOps getOpcode() const { return Opcode; }
/// Returns the result type of the cast.
- Type *getResultType() const { return ResultTy; }
+ Type *getResultType() const { return getScalarType(); }
protected:
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -1885,9 +1900,6 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
/// ID of the vector intrinsic to widen.
Intrinsic::ID VectorIntrinsicID;
- /// Scalar return type of the intrinsic.
- Type *ResultTy;
-
/// True if the intrinsic may read from memory.
bool MayReadFromMemory;
@@ -1903,9 +1915,9 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
const VPIRFlags &Flags = {},
const VPIRMetadata &MD = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments,
+ : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments, Ty,
Flags, DL),
- VPIRMetadata(MD), VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
+ VPIRMetadata(MD), VectorIntrinsicID(VectorIntrinsicID),
MayReadFromMemory(CI.mayReadFromMemory()),
MayWriteToMemory(CI.mayWriteToMemory()),
MayHaveSideEffects(CI.mayHaveSideEffects()) {
@@ -1917,10 +1929,9 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments,
+ : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments, Ty,
Flags, DL),
- VPIRMetadata(Metadata), VectorIntrinsicID(VectorIntrinsicID),
- ResultTy(Ty) {
+ VPIRMetadata(Metadata), VectorIntrinsicID(VectorIntrinsicID) {
LLVMContext &Ctx = Ty->getContext();
AttributeSet Attrs = Intrinsic::getFnAttributes(Ctx, VectorIntrinsicID);
MemoryEffects ME = Attrs.getMemoryEffects();
@@ -1936,10 +1947,11 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
VPWidenIntrinsicRecipe *clone() override {
if (Value *CI = getUnderlyingValue())
return new VPWidenIntrinsicRecipe(*cast<CallInst>(CI), VectorIntrinsicID,
- operands(), ResultTy, *this, *this,
- getDebugLoc());
- return new VPWidenIntrinsicRecipe(VectorIntrinsicID, operands(), ResultTy,
- *this, *this, getDebugLoc());
+ operands(), getResultType(), *this,
+ *this, getDebugLoc());
+ return new VPWidenIntrinsicRecipe(VectorIntrinsicID, operands(),
+ getResultType(), *this, *this,
+ getDebugLoc());
}
VP_CLASSOF_IMPL(VPRecipeBase::VPWidenIntrinsicSC)
@@ -1955,7 +1967,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
Intrinsic::ID getVectorIntrinsicID() const { return VectorIntrinsicID; }
/// Return the scalar return type of the intrinsic.
- Type *getResultType() const { return ResultTy; }
+ Type *getResultType() const { return getScalarType(); }
/// Return to name of the intrinsic as string.
StringRef getIntrinsicName() const;
@@ -1992,8 +2004,11 @@ class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags,
ArrayRef<VPValue *> CallArguments,
const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {}, DebugLoc DL = {})
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCallSC, CallArguments, Flags,
- DL),
+ : VPRecipeWithIRFlags(
+ VPRecipeBase::VPWidenCallSC, CallArguments,
+ cast<Function>(CallArguments.back()->getLiveInIRValue())
+ ->getReturnType(),
+ Flags, DL),
VPIRMetadata(Metadata), Variant(Variant) {
setUnderlyingValue(UV);
assert(
@@ -2094,7 +2109,8 @@ class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags {
VPWidenGEPRecipe(GetElementPtrInst *GEP, ArrayRef<VPValue *> Operands,
const VPIRFlags &Flags = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenGEPSC, Operands, Flags, DL),
+ : VPRecipeWithIRFlags(VPRecipeBase::VPWidenGEPSC, Operands,
+ getScalarTypeOrInfer(Operands[0]), Flags, DL),
SourceElementTy(GEP->getSourceElementType()) {
setUnderlyingValue(GEP);
SmallVector<std::pair<unsigned, MDNode *>> Metadata;
@@ -2154,7 +2170,7 @@ class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags {
VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *SourceElementTy,
int64_t Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL)
: VPRecipeWithIRFlags(VPRecipeBase::VPVectorEndPointerSC, {Ptr, VF},
- GEPFlags, DL),
+ getScalarTypeOrInfer(Ptr), GEPFlags, DL),
SourceElementTy(SourceElementTy), Stride(Stride) {
assert(Stride < 0 && "Stride must be negative");
}
@@ -2222,7 +2238,8 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags {
public:
VPVectorPointerRecipe(VPValue *Ptr, Type *SourceElementTy,
GEPNoWrapFlags GEPFlags, DebugLoc DL)
- : VPRecipeWithIRFlags(VPRecipeBase::VPVectorPointerSC, Ptr, GEPFlags, DL),
+ : VPRecipeWithIRFlags(VPRecipeBase::VPVectorPointerSC, Ptr,
+ getScalarTypeOrInfer(Ptr), GEPFlags, DL),
SourceElementTy(SourceElementTy) {}
VP_CLASSOF_IMPL(VPRecipeBase::VPVectorPointerSC)
@@ -2581,11 +2598,13 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
std::string Name;
public:
- /// Create a new VPWidenPHIRecipe with incoming values \p IncomingvValues,
+ /// Create a new VPWidenPHIRecipe with incoming values \p IncomingValues,
/// debug location \p DL and \p Name.
VPWidenPHIRecipe(ArrayRef<VPValue *> IncomingValues,
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "")
- : VPSingleDefRecipe(VPRecipeBase::VPWidenPHISC, IncomingValues, DL),
+ : VPSingleDefRecipe(VPRecipeBase::VPWidenPHISC, IncomingValues,
+ getScalarTypeOrInfer(IncomingValues[0]),
+ /*UV=*/nullptr, DL),
Name(Name.str()) {}
VPWidenPHIRecipe *clone() override {
@@ -2707,7 +2726,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe, public VPIRFlags {
VPReductionPHIRecipe *clone() override {
return new VPReductionPHIRecipe(
dyn_cast_or_null<PHINode>(getUnderlyingValue()), getRecurrenceKind(),
- *getOperand(0), *getBackedgeValue(), Style, *this,
+ *getStartValue(), *getBackedgeValue(), Style, *this,
HasUsesOutsideReductionChain);
}
@@ -2869,7 +2888,7 @@ class LLVM_ABI_FOR_TEST VPInterleaveBase : public VPRecipeBase,
if (StoredValues.empty()) {
for (Instruction *Inst : IG->members()) {
assert(!Inst->getType()->isVoidTy() && "must have result");
- new VPRecipeValue(this, Inst);
+ new VPStandaloneRecipeValue(this, Inst, Inst->getType());
}
} else {
for (auto *SV : StoredValues)
@@ -3460,7 +3479,8 @@ class LLVM_ABI_FOR_TEST VPPredInstPHIRecipe : public VPSingleDefRecipe {
/// Construct a VPPredInstPHIRecipe given \p PredInst whose value needs a phi
/// nodes after merging back from a Branch-on-Mask.
VPPredInstPHIRecipe(VPValue *PredV, DebugLoc DL)
- : VPSingleDefRecipe(VPRecipeBase::VPPredInstPHISC, PredV, DL) {}
+ : VPSingleDefRecipe(VPRecipeBase::VPPredInstPHISC, PredV,
+ getScalarTypeOrInfer(PredV), nullptr, DL) {}
~VPPredInstPHIRecipe() override = default;
VPPredInstPHIRecipe *clone() override {
@@ -3576,13 +3596,14 @@ class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase,
/// A recipe for widening load operations, using the address to load from and an
/// optional mask.
-struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
- public VPRecipeValue {
+struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final
+ : public VPWidenMemoryRecipe,
+ public VPStandaloneRecipeValue {
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask,
bool Consecutive, const VPIRMetadata &Metadata, DebugLoc DL)
: VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadSC, Load, {Addr},
Consecutive, Metadata, DL),
- VPRecipeValue(this, &Load) {
+ VPStandaloneRecipeValue(this, &Load, Load.getType()) {
setMask(Mask);
}
@@ -3617,13 +3638,14 @@ struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
/// using the address to load from, the explicit vector length and an optional
/// mask.
struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe,
- public VPRecipeValue {
+ public VPStandaloneRecipeValue {
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Addr, VPValue &EVL,
VPValue *Mask)
: VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadEVLSC, L.getIngredient(),
{Addr, &EVL}, L.isConsecutive(), L,
L.getDebugLoc()),
- VPRecipeValue(this, &getIngredient()) {
+ VPStandaloneRecipeValue(this, &getIngredient(),
+ getIngredient().getType()) {
setMask(Mask);
}
@@ -3752,8 +3774,7 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe {
const SCEV *Expr;
public:
- VPExpandSCEVRecipe(const SCEV *Expr)
- : VPSingleDefRecipe(VPRecipeBase::VPExpandSCEVSC, {}), Expr(Expr) {}
+ VPExpandSCEVRecipe(const SCEV *Expr);
~VPExpandSCEVRecipe() override = default;
@@ -3862,7 +3883,8 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe,
public VPUnrollPartAccessor<1> {
public:
VPWidenCanonicalIVRecipe(VPRegionValue *CanonicalIV)
- : VPSingleDefRecipe(VPRecipeBase::VPWidenCanonicalIVSC, {CanonicalIV}) {}
+ : VPSingleDefRecipe(VPRecipeBase::VPWidenCanonicalIVSC, {CanonicalIV},
+ CanonicalIV->getType(), /*UV=*/nullptr) {}
~VPWidenCanonicalIVRecipe() override = default;
@@ -3979,7 +4001,7 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
Instruction::BinaryOps Opcode, FastMathFlags FMFs,
DebugLoc DL)
: VPRecipeWithIRFlags(VPRecipeBase::VPScalarIVStepsSC, {IV, Step, VF},
- FMFs, DL),
+ getScalarTypeOrInfer(IV), FMFs, DL),
InductionOpcode(Opcode) {}
VPScalarIVStepsRecipe(const InductionDescriptor &IndDesc, VPValue *IV,
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index 5697856559bc2..1367bd99131f4 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -204,17 +204,6 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPWidenRecipe *R) {
llvm_unreachable("Unhandled opcode!");
}
-Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPWidenCallRecipe *R) {
- auto &CI = *cast<CallInst>(R->getUnderlyingInstr());
- return CI.getType();
-}
-
-Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPWidenMemoryRecipe *R) {
- assert((isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(R)) &&
- "Store recipes should not define any values");
- return cast<LoadInst>(&R->getIngredient())->getType();
-}
-
Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPReplicateRecipe *R) {
unsigned Opcode = R->getUnderlyingInstr()->getOpcode();
@@ -275,17 +264,21 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
if (Type *CachedTy = CachedTypes.lookup(V))
return CachedTy;
- if (auto *IRV = dyn_cast<VPIRValue>(V))
- return IRV->getType();
-
if (isa<VPSymbolicValue>(V)) {
// All VPValues without any underlying IR value (like the vector trip count
// or the backedge-taken count) have the same type as the canonical IV.
return CanonicalIVTy;
}
- if (auto *RegionV = dyn_cast<VPRegionValue>(V))
- return RegionV->getType();
+ if (isa<VPIRValue, VPRegionValue, VPStandaloneRecipeValue, VPExpandSCEVRecipe,
+ VPWidenPHIRecipe, VPPredInstPHIRecipe, VPScalarIVStepsRecipe,
+ VPWidenCanonicalIVRecipe, VPWidenCastRecipe, VPWidenIntrinsicRecipe,
+ VPWidenGEPRecipe, VPVectorPointerRecipe, VPVectorEndPointerRecipe,
+ VPWidenCallRecipe>(V)) {
+ Type *Ty = V->getScalarType();
+ assert(Ty && "Scalar type must be set by recipe construction");
+ return Ty;
+ }
Type *ResultTy =
TypeSwitch<const VPRecipeBase *, Type *>(V->getDefiningRecipe())
@@ -300,26 +293,11 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
})
.Case<VPWidenIntOrFpInductionRecipe, VPDerivedIVRecipe>(
[](const auto *R) { return R->getScalarType(); })
- .Case<VPRedu...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/195485
More information about the llvm-commits
mailing list