Skip to content

Commit 661356c

Browse files
Addressed latest comments
1 parent dd5a4bb commit 661356c

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,15 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
14271427
return R;
14281428
}
14291429

1430-
VP_CLASSOF_IMPL(VPDef::VPWidenSC)
1430+
static inline bool classof(const VPRecipeBase *R) {
1431+
return R->getVPDefID() == VPRecipeBase::VPWidenSC ||
1432+
R->getVPDefID() == VPRecipeBase::VPWidenEVLSC;
1433+
}
1434+
1435+
static inline bool classof(const VPUser *U) {
1436+
auto *R = dyn_cast<VPRecipeBase>(U);
1437+
return R && classof(R);
1438+
}
14311439

14321440
/// Produce a widened instruction using the opcode and operands of the recipe,
14331441
/// processing State.VF elements.
@@ -1442,6 +1450,8 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
14421450
#endif
14431451
};
14441452

1453+
/// A recipe for widening operations with vector-predication intrinsics.with
1454+
/// explicit vector length (EVL).
14451455
class VPWidenEVLRecipe : public VPWidenRecipe {
14461456
using VPRecipeWithIRFlags::transferFlags;
14471457

@@ -1459,7 +1469,7 @@ class VPWidenEVLRecipe : public VPWidenRecipe {
14591469
~VPWidenEVLRecipe() override = default;
14601470

14611471
VPWidenRecipe *clone() override final {
1462-
llvm_unreachable("VPWidenStoreEVLRecipe cannot be cloned");
1472+
llvm_unreachable("VPWidenEVLRecipe cannot be cloned");
14631473
return nullptr;
14641474
}
14651475

@@ -2293,7 +2303,7 @@ class VPReductionRecipe : public VPSingleDefRecipe {
22932303
/// The Operands are {ChainOp, VecOp, EVL, [Condition]}.
22942304
class VPReductionEVLRecipe : public VPReductionRecipe {
22952305
public:
2296-
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue *CondOp, VPValue &EVL)
2306+
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp)
22972307
: VPReductionRecipe(
22982308
VPDef::VPReductionEVLSC, R.getRecurrenceDescriptor(),
22992309
cast_or_null<Instruction>(R.getUnderlyingValue()),
@@ -2605,7 +2615,7 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
26052615
/// using the address to load from, the explicit vector length and an optional
26062616
/// mask.
26072617
struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2608-
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Mask, VPValue &EVL)
2618+
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
26092619
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
26102620
{L.getAddr(), &EVL}, L.isConsecutive(),
26112621
L.isReverse(), L.getDebugLoc()),
@@ -2686,7 +2696,7 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
26862696
/// using the value to store, the address to store to, the explicit vector
26872697
/// length and an optional mask.
26882698
struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2689-
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue *Mask, VPValue &EVL)
2699+
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
26902700
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
26912701
{S.getAddr(), S.getStoredValue(), &EVL},
26922702
S.isConsecutive(), S.isReverse(), S.getDebugLoc()) {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,11 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14241424
TypeSwitch<VPRecipeBase *, VPRecipeBase *>(CurRecipe)
14251425
.Case<VPWidenLoadRecipe>([&](VPWidenLoadRecipe *L) {
14261426
VPValue *NewMask = GetNewMask(L->getMask());
1427-
return new VPWidenLoadEVLRecipe(*L, NewMask, EVL);
1427+
return new VPWidenLoadEVLRecipe(*L, EVL, NewMask);
14281428
})
14291429
.Case<VPWidenStoreRecipe>([&](VPWidenStoreRecipe *S) {
14301430
VPValue *NewMask = GetNewMask(S->getMask());
1431-
return new VPWidenStoreEVLRecipe(*S, NewMask, EVL);
1431+
return new VPWidenStoreEVLRecipe(*S, EVL, NewMask);
14321432
})
14331433
.Case<VPWidenRecipe>([&](VPWidenRecipe *W) -> VPRecipeBase * {
14341434
unsigned Opcode = W->getOpcode();
@@ -1438,8 +1438,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14381438
return new VPWidenEVLRecipe(W, EVL);
14391439
})
14401440
.Case<VPReductionRecipe>([&](VPReductionRecipe *Red) {
1441-
return new VPReductionEVLRecipe(
1442-
*Red, GetNewMask(Red->getCondOp()), EVL);
1441+
return new VPReductionEVLRecipe(*Red, EVL,
1442+
GetNewMask(Red->getCondOp()));
14431443
})
14441444
.Default([&](VPRecipeBase *R) { return nullptr; });
14451445

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ TEST(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
11401140
VPReductionRecipe Recipe(RecurrenceDescriptor(), nullptr, &ChainOp, &CondOp,
11411141
&VecOp, false);
11421142
VPValue EVL;
1143-
VPReductionEVLRecipe EVLRecipe(Recipe, &CondOp, EVL);
1143+
VPReductionEVLRecipe EVLRecipe(Recipe, EVL, &CondOp);
11441144
EXPECT_FALSE(EVLRecipe.mayHaveSideEffects());
11451145
EXPECT_FALSE(EVLRecipe.mayReadFromMemory());
11461146
EXPECT_FALSE(EVLRecipe.mayWriteToMemory());
@@ -1495,7 +1495,7 @@ TEST(VPRecipeTest, CastVPReductionEVLRecipeToVPUser) {
14951495
VPReductionRecipe Recipe(RecurrenceDescriptor(), nullptr, &ChainOp, &CondOp,
14961496
&VecOp, false);
14971497
VPValue EVL;
1498-
VPReductionEVLRecipe EVLRecipe(Recipe, &CondOp, EVL);
1498+
VPReductionEVLRecipe EVLRecipe(Recipe, EVL, &CondOp);
14991499
EXPECT_TRUE(isa<VPUser>(&EVLRecipe));
15001500
VPRecipeBase *BaseR = &EVLRecipe;
15011501
EXPECT_TRUE(isa<VPUser>(BaseR));

0 commit comments

Comments
 (0)