mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 08:06:40 +00:00
[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
This commit is contained in:
parent
a245a984fd
commit
35d3625a4d
@ -9227,46 +9227,6 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
|
||||
State.ILV->scalarizeInstruction(UI, this, VPIteration(Part, Lane), State);
|
||||
}
|
||||
|
||||
void VPWidenLoadRecipe::execute(VPTransformState &State) {
|
||||
auto *LI = cast<LoadInst>(&Ingredient);
|
||||
|
||||
Type *ScalarDataTy = getLoadStoreType(&Ingredient);
|
||||
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
|
||||
const Align Alignment = getLoadStoreAlignment(&Ingredient);
|
||||
bool CreateGather = !isConsecutive();
|
||||
|
||||
auto &Builder = State.Builder;
|
||||
State.setDebugLocFrom(getDebugLoc());
|
||||
for (unsigned Part = 0; Part < State.UF; ++Part) {
|
||||
Value *NewLI;
|
||||
Value *Mask = nullptr;
|
||||
if (auto *VPMask = getMask()) {
|
||||
// Mask reversal is only needed for non-all-one (null) masks, as reverse
|
||||
// of a null all-one mask is a null mask.
|
||||
Mask = State.get(VPMask, Part);
|
||||
if (isReverse())
|
||||
Mask = Builder.CreateVectorReverse(Mask, "reverse");
|
||||
}
|
||||
|
||||
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateGather);
|
||||
if (CreateGather) {
|
||||
NewLI = Builder.CreateMaskedGather(DataTy, Addr, Alignment, Mask, nullptr,
|
||||
"wide.masked.gather");
|
||||
} else if (Mask) {
|
||||
NewLI = Builder.CreateMaskedLoad(DataTy, Addr, Alignment, Mask,
|
||||
PoisonValue::get(DataTy),
|
||||
"wide.masked.load");
|
||||
} else {
|
||||
NewLI = Builder.CreateAlignedLoad(DataTy, Addr, Alignment, "wide.load");
|
||||
}
|
||||
// Add metadata to the load, but setVectorValue to the reverse shuffle.
|
||||
State.addMetadata(NewLI, LI);
|
||||
if (Reverse)
|
||||
NewLI = Builder.CreateVectorReverse(NewLI, "reverse");
|
||||
State.set(this, NewLI, Part);
|
||||
}
|
||||
}
|
||||
|
||||
/// Use all-true mask for reverse rather than actual mask, as it avoids a
|
||||
/// dependence w/o affecting the result.
|
||||
static Instruction *createReverseEVL(IRBuilderBase &Builder, Value *Operand,
|
||||
|
@ -2007,7 +2007,49 @@ void VPPredInstPHIRecipe::print(raw_ostream &O, const Twine &Indent,
|
||||
O << " = ";
|
||||
printOperands(O, SlotTracker);
|
||||
}
|
||||
#endif
|
||||
|
||||
void VPWidenLoadRecipe::execute(VPTransformState &State) {
|
||||
auto *LI = cast<LoadInst>(&Ingredient);
|
||||
|
||||
Type *ScalarDataTy = getLoadStoreType(&Ingredient);
|
||||
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
|
||||
const Align Alignment = getLoadStoreAlignment(&Ingredient);
|
||||
bool CreateGather = !isConsecutive();
|
||||
|
||||
auto &Builder = State.Builder;
|
||||
State.setDebugLocFrom(getDebugLoc());
|
||||
for (unsigned Part = 0; Part < State.UF; ++Part) {
|
||||
Value *NewLI;
|
||||
Value *Mask = nullptr;
|
||||
if (auto *VPMask = getMask()) {
|
||||
// Mask reversal is only needed for non-all-one (null) masks, as reverse
|
||||
// of a null all-one mask is a null mask.
|
||||
Mask = State.get(VPMask, Part);
|
||||
if (isReverse())
|
||||
Mask = Builder.CreateVectorReverse(Mask, "reverse");
|
||||
}
|
||||
|
||||
Value *Addr = State.get(getAddr(), Part, /*IsScalar*/ !CreateGather);
|
||||
if (CreateGather) {
|
||||
NewLI = Builder.CreateMaskedGather(DataTy, Addr, Alignment, Mask, nullptr,
|
||||
"wide.masked.gather");
|
||||
} else if (Mask) {
|
||||
NewLI = Builder.CreateMaskedLoad(DataTy, Addr, Alignment, Mask,
|
||||
PoisonValue::get(DataTy),
|
||||
"wide.masked.load");
|
||||
} else {
|
||||
NewLI = Builder.CreateAlignedLoad(DataTy, Addr, Alignment, "wide.load");
|
||||
}
|
||||
// Add metadata to the load, but setVectorValue to the reverse shuffle.
|
||||
State.addMetadata(NewLI, LI);
|
||||
if (Reverse)
|
||||
NewLI = Builder.CreateVectorReverse(NewLI, "reverse");
|
||||
State.set(this, NewLI, Part);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
||||
void VPWidenLoadRecipe::print(raw_ostream &O, const Twine &Indent,
|
||||
VPSlotTracker &SlotTracker) const {
|
||||
O << Indent << "WIDEN ";
|
||||
|
Loading…
x
Reference in New Issue
Block a user