Skip to content

Commit 3834523

Browse files
authored
[LV][EVL] Refine the constructors of EVL recipe to use call by reference. NFC (#100088)
1 parent 8d937c6 commit 3834523

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,12 +2246,12 @@ class VPReductionRecipe : public VPSingleDefRecipe {
22462246
/// The Operands are {ChainOp, VecOp, EVL, [Condition]}.
22472247
class VPReductionEVLRecipe : public VPReductionRecipe {
22482248
public:
2249-
VPReductionEVLRecipe(VPReductionRecipe *R, VPValue *EVL, VPValue *CondOp)
2249+
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp)
22502250
: VPReductionRecipe(
2251-
VPDef::VPReductionEVLSC, R->getRecurrenceDescriptor(),
2252-
cast_or_null<Instruction>(R->getUnderlyingValue()),
2253-
ArrayRef<VPValue *>({R->getChainOp(), R->getVecOp(), EVL}), CondOp,
2254-
R->isOrdered()) {}
2251+
VPDef::VPReductionEVLSC, R.getRecurrenceDescriptor(),
2252+
cast_or_null<Instruction>(R.getUnderlyingValue()),
2253+
ArrayRef<VPValue *>({R.getChainOp(), R.getVecOp(), &EVL}), CondOp,
2254+
R.isOrdered()) {}
22552255

22562256
~VPReductionEVLRecipe() override = default;
22572257

@@ -2558,10 +2558,10 @@ struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue {
25582558
/// using the address to load from, the explicit vector length and an optional
25592559
/// mask.
25602560
struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
2561-
VPWidenLoadEVLRecipe(VPWidenLoadRecipe *L, VPValue *EVL, VPValue *Mask)
2562-
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L->getIngredient(),
2563-
{L->getAddr(), EVL}, L->isConsecutive(),
2564-
L->isReverse(), L->getDebugLoc()),
2561+
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
2562+
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
2563+
{L.getAddr(), &EVL}, L.isConsecutive(),
2564+
L.isReverse(), L.getDebugLoc()),
25652565
VPValue(this, &getIngredient()) {
25662566
setMask(Mask);
25672567
}
@@ -2634,11 +2634,10 @@ struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
26342634
/// using the value to store, the address to store to, the explicit vector
26352635
/// length and an optional mask.
26362636
struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
2637-
VPWidenStoreEVLRecipe(VPWidenStoreRecipe *S, VPValue *EVL, VPValue *Mask)
2638-
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S->getIngredient(),
2639-
{S->getAddr(), S->getStoredValue(), EVL},
2640-
S->isConsecutive(), S->isReverse(),
2641-
S->getDebugLoc()) {
2637+
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
2638+
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
2639+
{S.getAddr(), S.getStoredValue(), &EVL},
2640+
S.isConsecutive(), S.isReverse(), S.getDebugLoc()) {
26422641
setMask(Mask);
26432642
}
26442643

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,13 +1488,13 @@ bool VPlanTransforms::tryAddExplicitVectorLength(VPlan &Plan) {
14881488
if (auto *MemR = dyn_cast<VPWidenMemoryRecipe>(CurRecipe)) {
14891489
VPValue *NewMask = GetNewMask(MemR->getMask());
14901490
if (auto *L = dyn_cast<VPWidenLoadRecipe>(MemR))
1491-
NewRecipe = new VPWidenLoadEVLRecipe(L, VPEVL, NewMask);
1491+
NewRecipe = new VPWidenLoadEVLRecipe(*L, *VPEVL, NewMask);
14921492
else if (auto *S = dyn_cast<VPWidenStoreRecipe>(MemR))
1493-
NewRecipe = new VPWidenStoreEVLRecipe(S, VPEVL, NewMask);
1493+
NewRecipe = new VPWidenStoreEVLRecipe(*S, *VPEVL, NewMask);
14941494
else
14951495
llvm_unreachable("unsupported recipe");
14961496
} else if (auto *RedR = dyn_cast<VPReductionRecipe>(CurRecipe)) {
1497-
NewRecipe = new VPReductionEVLRecipe(RedR, VPEVL,
1497+
NewRecipe = new VPReductionEVLRecipe(*RedR, *VPEVL,
14981498
GetNewMask(RedR->getCondOp()));
14991499
}
15001500

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, &EVL, &CondOp);
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, &EVL, &CondOp);
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)