Skip to content

Commit 73a7df3

Browse files
Addressed latest comments
1 parent 9cffa8f commit 73a7df3

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

@@ -2319,7 +2329,7 @@ class VPReductionRecipe : public VPSingleDefRecipe {
23192329
/// The Operands are {ChainOp, VecOp, EVL, [Condition]}.
23202330
class VPReductionEVLRecipe : public VPReductionRecipe {
23212331
public:
2322-
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue *CondOp, VPValue &EVL)
2332+
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp)
23232333
: VPReductionRecipe(
23242334
VPDef::VPReductionEVLSC, R.getRecurrenceDescriptor(),
23252335
cast_or_null<Instruction>(R.getUnderlyingValue()),
@@ -2635,7 +2645,7 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
26352645
/// using the address to load from, the explicit vector length and an optional
26362646
/// mask.
26372647
struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2638-
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Mask, VPValue &EVL)
2648+
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
26392649
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
26402650
{L.getAddr(), &EVL}, L.isConsecutive(),
26412651
L.isReverse(), L.getDebugLoc()),
@@ -2716,7 +2726,7 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
27162726
/// using the value to store, the address to store to, the explicit vector
27172727
/// length and an optional mask.
27182728
struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2719-
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue *Mask, VPValue &EVL)
2729+
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
27202730
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
27212731
{S.getAddr(), S.getStoredValue(), &EVL},
27222732
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
@@ -1334,11 +1334,11 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13341334
TypeSwitch<VPRecipeBase *, VPRecipeBase *>(CurRecipe)
13351335
.Case<VPWidenLoadRecipe>([&](VPWidenLoadRecipe *L) {
13361336
VPValue *NewMask = GetNewMask(L->getMask());
1337-
return new VPWidenLoadEVLRecipe(*L, NewMask, EVL);
1337+
return new VPWidenLoadEVLRecipe(*L, EVL, NewMask);
13381338
})
13391339
.Case<VPWidenStoreRecipe>([&](VPWidenStoreRecipe *S) {
13401340
VPValue *NewMask = GetNewMask(S->getMask());
1341-
return new VPWidenStoreEVLRecipe(*S, NewMask, EVL);
1341+
return new VPWidenStoreEVLRecipe(*S, EVL, NewMask);
13421342
})
13431343
.Case<VPWidenRecipe>([&](VPWidenRecipe *W) -> VPRecipeBase * {
13441344
unsigned Opcode = W->getOpcode();
@@ -1348,8 +1348,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13481348
return new VPWidenEVLRecipe(W, EVL);
13491349
})
13501350
.Case<VPReductionRecipe>([&](VPReductionRecipe *Red) {
1351-
return new VPReductionEVLRecipe(
1352-
*Red, GetNewMask(Red->getCondOp()), EVL);
1351+
return new VPReductionEVLRecipe(*Red, EVL,
1352+
GetNewMask(Red->getCondOp()));
13531353
})
13541354
.Default([&](VPRecipeBase *R) { return nullptr; });
13551355

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)