Skip to content

Commit 0fbee10

Browse files
Addressed latest comments
1 parent 8019e6f commit 0fbee10

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
@@ -1431,7 +1431,15 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
14311431
return R;
14321432
}
14331433

1434-
VP_CLASSOF_IMPL(VPDef::VPWidenSC)
1434+
static inline bool classof(const VPRecipeBase *R) {
1435+
return R->getVPDefID() == VPRecipeBase::VPWidenSC ||
1436+
R->getVPDefID() == VPRecipeBase::VPWidenEVLSC;
1437+
}
1438+
1439+
static inline bool classof(const VPUser *U) {
1440+
auto *R = dyn_cast<VPRecipeBase>(U);
1441+
return R && classof(R);
1442+
}
14351443

14361444
/// Produce a widened instruction using the opcode and operands of the recipe,
14371445
/// processing State.VF elements.
@@ -1450,6 +1458,8 @@ class VPWidenRecipe : public VPRecipeWithIRFlags {
14501458
#endif
14511459
};
14521460

1461+
/// A recipe for widening operations with vector-predication intrinsics.with
1462+
/// explicit vector length (EVL).
14531463
class VPWidenEVLRecipe : public VPWidenRecipe {
14541464
using VPRecipeWithIRFlags::transferFlags;
14551465

@@ -1467,7 +1477,7 @@ class VPWidenEVLRecipe : public VPWidenRecipe {
14671477
~VPWidenEVLRecipe() override = default;
14681478

14691479
VPWidenRecipe *clone() override final {
1470-
llvm_unreachable("VPWidenStoreEVLRecipe cannot be cloned");
1480+
llvm_unreachable("VPWidenEVLRecipe cannot be cloned");
14711481
return nullptr;
14721482
}
14731483

@@ -2309,7 +2319,7 @@ class VPReductionRecipe : public VPSingleDefRecipe {
23092319
/// The Operands are {ChainOp, VecOp, EVL, [Condition]}.
23102320
class VPReductionEVLRecipe : public VPReductionRecipe {
23112321
public:
2312-
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue *CondOp, VPValue &EVL)
2322+
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp)
23132323
: VPReductionRecipe(
23142324
VPDef::VPReductionEVLSC, R.getRecurrenceDescriptor(),
23152325
cast_or_null<Instruction>(R.getUnderlyingValue()),
@@ -2621,7 +2631,7 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
26212631
/// using the address to load from, the explicit vector length and an optional
26222632
/// mask.
26232633
struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2624-
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Mask, VPValue &EVL)
2634+
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
26252635
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
26262636
{L.getAddr(), &EVL}, L.isConsecutive(),
26272637
L.isReverse(), L.getDebugLoc()),
@@ -2702,7 +2712,7 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
27022712
/// using the value to store, the address to store to, the explicit vector
27032713
/// length and an optional mask.
27042714
struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2705-
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue *Mask, VPValue &EVL)
2715+
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
27062716
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
27072717
{S.getAddr(), S.getStoredValue(), &EVL},
27082718
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)