Skip to content

Commit d187404

Browse files
authored
[VPlan] Retrieve alignment from Load/StoreInst in constructors. nfc (#165722)
This patch removes the explicit Alignment parameter from VPWidenLoadRecipe and VPWidenStoreRecipe constructors. Instead, these recipes now directly retrieve the alignment from their LoadInst/StoreInst.
1 parent a928c61 commit d187404

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7550,13 +7550,12 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
75507550
}
75517551
if (LoadInst *Load = dyn_cast<LoadInst>(I))
75527552
return new VPWidenLoadRecipe(*Load, Ptr, Mask, Consecutive, Reverse,
7553-
Load->getAlign(), VPIRMetadata(*Load, LVer),
7554-
I->getDebugLoc());
7553+
VPIRMetadata(*Load, LVer), I->getDebugLoc());
75557554

75567555
StoreInst *Store = cast<StoreInst>(I);
75577556
return new VPWidenStoreRecipe(*Store, Ptr, Operands[0], Mask, Consecutive,
7558-
Reverse, Store->getAlign(),
7559-
VPIRMetadata(*Store, LVer), I->getDebugLoc());
7557+
Reverse, VPIRMetadata(*Store, LVer),
7558+
I->getDebugLoc());
75607559
}
75617560

75627561
/// Creates a VPWidenIntOrFpInductionRecpipe for \p Phi. If needed, it will also

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,10 +3206,11 @@ class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase,
32063206

32073207
VPWidenMemoryRecipe(const char unsigned SC, Instruction &I,
32083208
std::initializer_list<VPValue *> Operands,
3209-
bool Consecutive, bool Reverse, Align Alignment,
3209+
bool Consecutive, bool Reverse,
32103210
const VPIRMetadata &Metadata, DebugLoc DL)
32113211
: VPRecipeBase(SC, Operands, DL), VPIRMetadata(Metadata), Ingredient(I),
3212-
Alignment(Alignment), Consecutive(Consecutive), Reverse(Reverse) {
3212+
Alignment(getLoadStoreAlignment(&I)), Consecutive(Consecutive),
3213+
Reverse(Reverse) {
32133214
assert((Consecutive || !Reverse) && "Reverse implies consecutive");
32143215
assert(isa<VPVectorEndPointerRecipe>(getAddr()) ||
32153216
!Reverse &&
@@ -3273,18 +3274,18 @@ class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase,
32733274
struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
32743275
public VPValue {
32753276
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask,
3276-
bool Consecutive, bool Reverse, Align Alignment,
3277+
bool Consecutive, bool Reverse,
32773278
const VPIRMetadata &Metadata, DebugLoc DL)
32783279
: VPWidenMemoryRecipe(VPDef::VPWidenLoadSC, Load, {Addr}, Consecutive,
3279-
Reverse, Alignment, Metadata, DL),
3280+
Reverse, Metadata, DL),
32803281
VPValue(this, &Load) {
32813282
setMask(Mask);
32823283
}
32833284

32843285
VPWidenLoadRecipe *clone() override {
32853286
return new VPWidenLoadRecipe(cast<LoadInst>(Ingredient), getAddr(),
3286-
getMask(), Consecutive, Reverse, getAlign(),
3287-
*this, getDebugLoc());
3287+
getMask(), Consecutive, Reverse, *this,
3288+
getDebugLoc());
32883289
}
32893290

32903291
VP_CLASSOF_IMPL(VPDef::VPWidenLoadSC);
@@ -3315,8 +3316,8 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
33153316
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Addr, VPValue &EVL,
33163317
VPValue *Mask)
33173318
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
3318-
{Addr, &EVL}, L.isConsecutive(), L.isReverse(),
3319-
L.getAlign(), L, L.getDebugLoc()),
3319+
{Addr, &EVL}, L.isConsecutive(), L.isReverse(), L,
3320+
L.getDebugLoc()),
33203321
VPValue(this, &getIngredient()) {
33213322
setMask(Mask);
33223323
}
@@ -3354,16 +3355,16 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue {
33543355
struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
33553356
VPWidenStoreRecipe(StoreInst &Store, VPValue *Addr, VPValue *StoredVal,
33563357
VPValue *Mask, bool Consecutive, bool Reverse,
3357-
Align Alignment, const VPIRMetadata &Metadata, DebugLoc DL)
3358+
const VPIRMetadata &Metadata, DebugLoc DL)
33583359
: VPWidenMemoryRecipe(VPDef::VPWidenStoreSC, Store, {Addr, StoredVal},
3359-
Consecutive, Reverse, Alignment, Metadata, DL) {
3360+
Consecutive, Reverse, Metadata, DL) {
33603361
setMask(Mask);
33613362
}
33623363

33633364
VPWidenStoreRecipe *clone() override {
33643365
return new VPWidenStoreRecipe(cast<StoreInst>(Ingredient), getAddr(),
33653366
getStoredValue(), getMask(), Consecutive,
3366-
Reverse, getAlign(), *this, getDebugLoc());
3367+
Reverse, *this, getDebugLoc());
33673368
}
33683369

33693370
VP_CLASSOF_IMPL(VPDef::VPWidenStoreSC);
@@ -3398,7 +3399,7 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
33983399
VPValue *Mask)
33993400
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
34003401
{Addr, S.getStoredValue(), &EVL}, S.isConsecutive(),
3401-
S.isReverse(), S.getAlign(), S, S.getDebugLoc()) {
3402+
S.isReverse(), S, S.getDebugLoc()) {
34023403
setMask(Mask);
34033404
}
34043405

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes(
9191
if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
9292
NewRecipe = new VPWidenLoadRecipe(
9393
*Load, Ingredient.getOperand(0), nullptr /*Mask*/,
94-
false /*Consecutive*/, false /*Reverse*/, Load->getAlign(),
95-
VPIRMetadata(*Load), Ingredient.getDebugLoc());
94+
false /*Consecutive*/, false /*Reverse*/, VPIRMetadata(*Load),
95+
Ingredient.getDebugLoc());
9696
} else if (StoreInst *Store = dyn_cast<StoreInst>(Inst)) {
9797
NewRecipe = new VPWidenStoreRecipe(
9898
*Store, Ingredient.getOperand(1), Ingredient.getOperand(0),
9999
nullptr /*Mask*/, false /*Consecutive*/, false /*Reverse*/,
100-
Store->getAlign(), VPIRMetadata(*Store),
101-
Ingredient.getDebugLoc());
100+
VPIRMetadata(*Store), Ingredient.getDebugLoc());
102101
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
103102
NewRecipe = new VPWidenGEPRecipe(GEP, Ingredient.operands());
104103
} else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {
@@ -4208,7 +4207,7 @@ narrowInterleaveGroupOp(VPValue *V, SmallPtrSetImpl<VPValue *> &NarrowedOps) {
42084207
auto *LI = cast<LoadInst>(LoadGroup->getInterleaveGroup()->getInsertPos());
42094208
auto *L = new VPWidenLoadRecipe(
42104209
*LI, LoadGroup->getAddr(), LoadGroup->getMask(), /*Consecutive=*/true,
4211-
/*Reverse=*/false, LI->getAlign(), {}, LoadGroup->getDebugLoc());
4210+
/*Reverse=*/false, {}, LoadGroup->getDebugLoc());
42124211
L->insertBefore(LoadGroup);
42134212
NarrowedOps.insert(L);
42144213
return L;
@@ -4345,7 +4344,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
43454344
cast<StoreInst>(StoreGroup->getInterleaveGroup()->getInsertPos());
43464345
auto *S = new VPWidenStoreRecipe(
43474346
*SI, StoreGroup->getAddr(), Res, nullptr, /*Consecutive=*/true,
4348-
/*Reverse=*/false, SI->getAlign(), {}, StoreGroup->getDebugLoc());
4347+
/*Reverse=*/false, {}, StoreGroup->getDebugLoc());
43494348
S->insertBefore(StoreGroup);
43504349
StoreGroup->eraseFromParent();
43514350
}

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,7 @@ TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) {
11321132
new LoadInst(Int32, PoisonValue::get(Int32Ptr), "", false, Align(1));
11331133
VPValue *Addr = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
11341134
VPValue *Mask = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
1135-
VPWidenLoadRecipe Recipe(*Load, Addr, Mask, true, false, Load->getAlign(), {},
1136-
{});
1135+
VPWidenLoadRecipe Recipe(*Load, Addr, Mask, true, false, {}, {});
11371136
EXPECT_TRUE(isa<VPUser>(&Recipe));
11381137
VPRecipeBase *BaseR = &Recipe;
11391138
EXPECT_TRUE(isa<VPUser>(BaseR));
@@ -1250,8 +1249,7 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
12501249
new LoadInst(Int32, PoisonValue::get(Int32Ptr), "", false, Align(1));
12511250
VPValue *Mask = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
12521251
VPValue *Addr = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
1253-
VPWidenLoadRecipe Recipe(*Load, Addr, Mask, true, false, Load->getAlign(),
1254-
{}, {});
1252+
VPWidenLoadRecipe Recipe(*Load, Addr, Mask, true, false, {}, {});
12551253
EXPECT_FALSE(Recipe.mayHaveSideEffects());
12561254
EXPECT_TRUE(Recipe.mayReadFromMemory());
12571255
EXPECT_FALSE(Recipe.mayWriteToMemory());
@@ -1265,8 +1263,8 @@ TEST_F(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
12651263
VPValue *Mask = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
12661264
VPValue *Addr = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
12671265
VPValue *StoredV = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 3));
1268-
VPWidenStoreRecipe Recipe(*Store, Addr, StoredV, Mask, false, false,
1269-
Store->getAlign(), {}, {});
1266+
VPWidenStoreRecipe Recipe(*Store, Addr, StoredV, Mask, false, false, {},
1267+
{});
12701268
EXPECT_TRUE(Recipe.mayHaveSideEffects());
12711269
EXPECT_FALSE(Recipe.mayReadFromMemory());
12721270
EXPECT_TRUE(Recipe.mayWriteToMemory());

0 commit comments

Comments
 (0)