Skip to content

Commit 35d3625

Browse files
committed
[VPlan] Move VPWidenLoadRecipe::execute to VPlanRecipes.cpp (NFC).
Move VPWidenLoadRecipe::execute to VPlanRecipes.cpp in line with other ::execute implementations that don't depend on anything defined in LoopVectorization.cpp
1 parent a245a98 commit 35d3625

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
@@ -9227,46 +9227,6 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
92279227
State.ILV->scalarizeInstruction(UI, this, VPIteration(Part, Lane), State);
92289228
}
92299229

9230-
void VPWidenLoadRecipe::execute(VPTransformState &State) {
9231-
auto *LI = cast<LoadInst>(&Ingredient);
9232-
9233-
Type *ScalarDataTy = getLoadStoreType(&Ingredient);
9234-
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
9235-
const Align Alignment = getLoadStoreAlignment(&Ingredient);
9236-
bool CreateGather = !isConsecutive();
9237-
9238-
auto &Builder = State.Builder;
9239-
State.setDebugLocFrom(getDebugLoc());
9240-
for (unsigned Part = 0; Part < State.UF; ++Part) {
9241-
Value *NewLI;
9242-
Value *Mask = nullptr;
9243-
if (auto *VPMask = getMask()) {
9244-
// Mask reversal is only needed for non-all-one (null) masks, as reverse
9245-
// of a null all-one mask is a null mask.
9246-
Mask = State.get(VPMask, Part);
9247-
if (isReverse())
9248-
Mask = Builder.CreateVectorReverse(Mask, "reverse");
9249-
}
9250-
9251-
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateGather);
9252-
if (CreateGather) {
9253-
NewLI = Builder.CreateMaskedGather(DataTy, Addr, Alignment, Mask, nullptr,
9254-
"wide.masked.gather");
9255-
} else if (Mask) {
9256-
NewLI = Builder.CreateMaskedLoad(DataTy, Addr, Alignment, Mask,
9257-
PoisonValue::get(DataTy),
9258-
"wide.masked.load");
9259-
} else {
9260-
NewLI = Builder.CreateAlignedLoad(DataTy, Addr, Alignment, "wide.load");
9261-
}
9262-
// Add metadata to the load, but setVectorValue to the reverse shuffle.
9263-
State.addMetadata(NewLI, LI);
9264-
if (Reverse)
9265-
NewLI = Builder.CreateVectorReverse(NewLI, "reverse");
9266-
State.set(this, NewLI, Part);
9267-
}
9268-
}
9269-
92709230
/// Use all-true mask for reverse rather than actual mask, as it avoids a
92719231
/// dependence w/o affecting the result.
92729232
static Instruction *createReverseEVL(IRBuilderBase &Builder, Value *Operand,

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,49 @@ void VPPredInstPHIRecipe::print(raw_ostream &O, const Twine &Indent,
20072007
O << " = ";
20082008
printOperands(O, SlotTracker);
20092009
}
2010+
#endif
2011+
2012+
void VPWidenLoadRecipe::execute(VPTransformState &State) {
2013+
auto *LI = cast<LoadInst>(&Ingredient);
2014+
2015+
Type *ScalarDataTy = getLoadStoreType(&Ingredient);
2016+
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
2017+
const Align Alignment = getLoadStoreAlignment(&Ingredient);
2018+
bool CreateGather = !isConsecutive();
2019+
2020+
auto &Builder = State.Builder;
2021+
State.setDebugLocFrom(getDebugLoc());
2022+
for (unsigned Part = 0; Part < State.UF; ++Part) {
2023+
Value *NewLI;
2024+
Value *Mask = nullptr;
2025+
if (auto *VPMask = getMask()) {
2026+
// Mask reversal is only needed for non-all-one (null) masks, as reverse
2027+
// of a null all-one mask is a null mask.
2028+
Mask = State.get(VPMask, Part);
2029+
if (isReverse())
2030+
Mask = Builder.CreateVectorReverse(Mask, "reverse");
2031+
}
20102032

2033+
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateGather);
2034+
if (CreateGather) {
2035+
NewLI = Builder.CreateMaskedGather(DataTy, Addr, Alignment, Mask, nullptr,
2036+
"wide.masked.gather");
2037+
} else if (Mask) {
2038+
NewLI = Builder.CreateMaskedLoad(DataTy, Addr, Alignment, Mask,
2039+
PoisonValue::get(DataTy),
2040+
"wide.masked.load");
2041+
} else {
2042+
NewLI = Builder.CreateAlignedLoad(DataTy, Addr, Alignment, "wide.load");
2043+
}
2044+
// Add metadata to the load, but setVectorValue to the reverse shuffle.
2045+
State.addMetadata(NewLI, LI);
2046+
if (Reverse)
2047+
NewLI = Builder.CreateVectorReverse(NewLI, "reverse");
2048+
State.set(this, NewLI, Part);
2049+
}
2050+
}
2051+
2052+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
20112053
void VPWidenLoadRecipe::print(raw_ostream &O, const Twine &Indent,
20122054
VPSlotTracker &SlotTracker) const {
20132055
O << Indent << "WIDEN ";

0 commit comments

Comments
 (0)