[llvm-branch-commits] [llvm] ad5b83d - [VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 25 03:13:11 PST 2020
Author: Florian Hahn
Date: 2020-11-25T11:08:25Z
New Revision: ad5b83ddcf45372f61b9602038006a2ec58dab4a
URL: https://github.com/llvm/llvm-project/commit/ad5b83ddcf45372f61b9602038006a2ec58dab4a
DIFF: https://github.com/llvm/llvm-project/commit/ad5b83ddcf45372f61b9602038006a2ec58dab4a.diff
LOG: [VPlan] Add VPReductionSC to VPUser::classof, unify VPValue IDs.
This is a follow-up to 00a66011366c7b037d6680e6015524a41b761c34 to make
isa<VPReductionRecipe> work and unifies the VPValue ID names, by making
sure they all consistently start with VPV*.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index fb7117b4ca8c..28595b9ec408 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -726,6 +726,7 @@ inline bool VPUser::classof(const VPRecipeBase *Recipe) {
Recipe->getVPRecipeID() == VPRecipeBase::VPBlendSC ||
Recipe->getVPRecipeID() == VPRecipeBase::VPInterleaveSC ||
Recipe->getVPRecipeID() == VPRecipeBase::VPReplicateSC ||
+ Recipe->getVPRecipeID() == VPRecipeBase::VPReductionSC ||
Recipe->getVPRecipeID() == VPRecipeBase::VPBranchOnMaskSC ||
Recipe->getVPRecipeID() == VPRecipeBase::VPWidenMemoryInstructionSC;
}
@@ -760,7 +761,7 @@ class VPInstruction : public VPUser, public VPValue, public VPRecipeBase {
public:
VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands)
- : VPUser(Operands), VPValue(VPValue::VPInstructionSC),
+ : VPUser(Operands), VPValue(VPValue::VPVInstructionSC),
VPRecipeBase(VPRecipeBase::VPInstructionSC), Opcode(Opcode) {}
VPInstruction(unsigned Opcode, std::initializer_list<VPValue *> Operands)
@@ -768,7 +769,7 @@ class VPInstruction : public VPUser, public VPValue, public VPRecipeBase {
/// Method to support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const VPValue *V) {
- return V->getVPValueID() == VPValue::VPInstructionSC;
+ return V->getVPValueID() == VPValue::VPVInstructionSC;
}
VPInstruction *clone() const {
@@ -832,7 +833,7 @@ class VPWidenRecipe : public VPRecipeBase, public VPValue, public VPUser {
public:
template <typename IterT>
VPWidenRecipe(Instruction &I, iterator_range<IterT> Operands)
- : VPRecipeBase(VPRecipeBase::VPWidenSC), VPValue(VPValue::VPWidenSC, &I),
+ : VPRecipeBase(VPRecipeBase::VPWidenSC), VPValue(VPValue::VPVWidenSC, &I),
VPUser(Operands) {}
~VPWidenRecipe() override = default;
@@ -842,7 +843,7 @@ class VPWidenRecipe : public VPRecipeBase, public VPValue, public VPUser {
return V->getVPRecipeID() == VPRecipeBase::VPWidenSC;
}
static inline bool classof(const VPValue *V) {
- return V->getVPValueID() == VPValue::VPWidenSC;
+ return V->getVPValueID() == VPValue::VPVWidenSC;
}
/// Produce widened copies of all Ingredients.
@@ -1086,7 +1087,7 @@ class VPReductionRecipe : public VPRecipeBase, public VPValue, public VPUser {
VPValue *VecOp, VPValue *CondOp, bool NoNaN,
const TargetTransformInfo *TTI)
: VPRecipeBase(VPRecipeBase::VPReductionSC),
- VPValue(VPValue::VPReductionSC, I), VPUser({ChainOp, VecOp}),
+ VPValue(VPValue::VPVReductionSC, I), VPUser({ChainOp, VecOp}),
RdxDesc(R), NoNaN(NoNaN), TTI(TTI) {
if (CondOp)
addOperand(CondOp);
@@ -1096,7 +1097,7 @@ class VPReductionRecipe : public VPRecipeBase, public VPValue, public VPUser {
/// Method to support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const VPValue *V) {
- return V->getVPValueID() == VPValue::VPReductionSC;
+ return V->getVPValueID() == VPValue::VPVReductionSC;
}
static inline bool classof(const VPRecipeBase *V) {
return V->getVPRecipeID() == VPRecipeBase::VPReductionSC;
@@ -1257,14 +1258,14 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
public:
VPWidenMemoryInstructionRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask)
: VPRecipeBase(VPWidenMemoryInstructionSC),
- VPValue(VPValue::VPMemoryInstructionSC, &Load), VPUser({Addr}) {
+ VPValue(VPValue::VPVMemoryInstructionSC, &Load), VPUser({Addr}) {
setMask(Mask);
}
VPWidenMemoryInstructionRecipe(StoreInst &Store, VPValue *Addr,
VPValue *StoredValue, VPValue *Mask)
: VPRecipeBase(VPWidenMemoryInstructionSC),
- VPValue(VPValue::VPMemoryInstructionSC, &Store),
+ VPValue(VPValue::VPVMemoryInstructionSC, &Store),
VPUser({Addr, StoredValue}) {
setMask(Mask);
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 0bc40112c9c5..9561abd10b5b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -87,10 +87,10 @@ class VPValue {
/// type identification.
enum {
VPValueSC,
- VPInstructionSC,
- VPMemoryInstructionSC,
- VPReductionSC,
- VPWidenSC,
+ VPVInstructionSC,
+ VPVMemoryInstructionSC,
+ VPVReductionSC,
+ VPVWidenSC,
VPVWidenCallSC,
VPVWidenGEPSC,
VPVWidenSelectSC,
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 9c65b3a3674a..d5c11396b303 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -521,6 +521,19 @@ TEST(VPRecipeTest, CastVPWidenMemoryInstructionRecipeToVPUser) {
delete Load;
}
+TEST(VPRecipeTest, CastVPReductionRecipeToVPUser) {
+ LLVMContext C;
+
+ VPValue ChainOp;
+ VPValue VecOp;
+ VPValue CondOp;
+ VPReductionRecipe Recipe(nullptr, nullptr, &ChainOp, &CondOp, &VecOp, false,
+ nullptr);
+ EXPECT_TRUE(isa<VPUser>(&Recipe));
+ VPRecipeBase *BaseR = &Recipe;
+ EXPECT_TRUE(isa<VPUser>(BaseR));
+}
+
struct VPDoubleValueDef : public VPUser, public VPDef {
VPDoubleValueDef(ArrayRef<VPValue *> Operands) : VPUser(Operands), VPDef() {
new VPValue(nullptr, this);
More information about the llvm-branch-commits
mailing list