Skip to content

Commit 12763a0

Browse files
committed
[VPlan] Move VPWidenStoreRecipe::execute to VPlanRecipes.cpp (NFC).
Move VPWidenStoreRecipe::execute to VPlanRecipes.cpp in line with other ::execute implementations that don't depend on anything defined in LoopVectorization.cpp
1 parent 3eaf483 commit 12763a0

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9363,46 +9363,6 @@ void VPWidenLoadEVLRecipe::execute(VPTransformState &State) {
93639363
State.set(this, Res, 0);
93649364
}
93659365

9366-
void VPWidenStoreRecipe::execute(VPTransformState &State) {
9367-
auto *SI = cast<StoreInst>(&Ingredient);
9368-
9369-
VPValue *StoredVPValue = getStoredValue();
9370-
bool CreateScatter = !isConsecutive();
9371-
const Align Alignment = getLoadStoreAlignment(&Ingredient);
9372-
9373-
auto &Builder = State.Builder;
9374-
State.setDebugLocFrom(getDebugLoc());
9375-
9376-
for (unsigned Part = 0; Part < State.UF; ++Part) {
9377-
Instruction *NewSI = nullptr;
9378-
Value *Mask = nullptr;
9379-
if (auto *VPMask = getMask()) {
9380-
// Mask reversal is only needed for non-all-one (null) masks, as reverse
9381-
// of a null all-one mask is a null mask.
9382-
Mask = State.get(VPMask, Part);
9383-
if (isReverse())
9384-
Mask = Builder.CreateVectorReverse(Mask, "reverse");
9385-
}
9386-
9387-
Value *StoredVal = State.get(StoredVPValue, Part);
9388-
if (isReverse()) {
9389-
// If we store to reverse consecutive memory locations, then we need
9390-
// to reverse the order of elements in the stored value.
9391-
StoredVal = Builder.CreateVectorReverse(StoredVal, "reverse");
9392-
// We don't want to update the value in the map as it might be used in
9393-
// another expression. So don't call resetVectorValue(StoredVal).
9394-
}
9395-
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateScatter);
9396-
if (CreateScatter)
9397-
NewSI = Builder.CreateMaskedScatter(StoredVal, Addr, Alignment, Mask);
9398-
else if (Mask)
9399-
NewSI = Builder.CreateMaskedStore(StoredVal, Addr, Alignment, Mask);
9400-
else
9401-
NewSI = Builder.CreateAlignedStore(StoredVal, Addr, Alignment);
9402-
State.addMetadata(NewSI, SI);
9403-
}
9404-
}
9405-
94069366
void VPWidenStoreEVLRecipe::execute(VPTransformState &State) {
94079367
assert(State.UF == 1 && "Expected only UF == 1 when vectorizing with "
94089368
"explicit vector length.");

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,49 @@ void VPWidenLoadEVLRecipe::print(raw_ostream &O, const Twine &Indent,
20662066
O << " = vp.load ";
20672067
printOperands(O, SlotTracker);
20682068
}
2069+
#endif
2070+
2071+
void VPWidenStoreRecipe::execute(VPTransformState &State) {
2072+
auto *SI = cast<StoreInst>(&Ingredient);
2073+
2074+
VPValue *StoredVPValue = getStoredValue();
2075+
bool CreateScatter = !isConsecutive();
2076+
const Align Alignment = getLoadStoreAlignment(&Ingredient);
2077+
2078+
auto &Builder = State.Builder;
2079+
State.setDebugLocFrom(getDebugLoc());
20692080

2081+
for (unsigned Part = 0; Part < State.UF; ++Part) {
2082+
Instruction *NewSI = nullptr;
2083+
Value *Mask = nullptr;
2084+
if (auto *VPMask = getMask()) {
2085+
// Mask reversal is only needed for non-all-one (null) masks, as reverse
2086+
// of a null all-one mask is a null mask.
2087+
Mask = State.get(VPMask, Part);
2088+
if (isReverse())
2089+
Mask = Builder.CreateVectorReverse(Mask, "reverse");
2090+
}
2091+
2092+
Value *StoredVal = State.get(StoredVPValue, Part);
2093+
if (isReverse()) {
2094+
// If we store to reverse consecutive memory locations, then we need
2095+
// to reverse the order of elements in the stored value.
2096+
StoredVal = Builder.CreateVectorReverse(StoredVal, "reverse");
2097+
// We don't want to update the value in the map as it might be used in
2098+
// another expression. So don't call resetVectorValue(StoredVal).
2099+
}
2100+
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateScatter);
2101+
if (CreateScatter)
2102+
NewSI = Builder.CreateMaskedScatter(StoredVal, Addr, Alignment, Mask);
2103+
else if (Mask)
2104+
NewSI = Builder.CreateMaskedStore(StoredVal, Addr, Alignment, Mask);
2105+
else
2106+
NewSI = Builder.CreateAlignedStore(StoredVal, Addr, Alignment);
2107+
State.addMetadata(NewSI, SI);
2108+
}
2109+
}
2110+
2111+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
20702112
void VPWidenStoreRecipe::print(raw_ostream &O, const Twine &Indent,
20712113
VPSlotTracker &SlotTracker) const {
20722114
O << Indent << "WIDEN store ";

0 commit comments

Comments
 (0)