Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3158,6 +3158,24 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
return *getCostForRecipeWithOpcode(getOpcode(), ElementCount::getFixed(1),
Ctx) *
(isSingleScalar() ? 1 : VF.getFixedValue());
case Instruction::Load:
case Instruction::Store: {
if (isSingleScalar()) {
bool IsLoad = UI->getOpcode() == Instruction::Load;
Type *ValTy = Ctx.Types.inferScalarType(IsLoad ? this : getOperand(0));
Type *ScalarPtrTy = Ctx.Types.inferScalarType(getOperand(IsLoad ? 0 : 1));
const Align Alignment = getLoadStoreAlignment(UI);
unsigned AS = getLoadStoreAddressSpace(UI);
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(UI->getOperand(0));
InstructionCost ScalarMemOpCost = Ctx.TTI.getMemoryOpCost(
UI->getOpcode(), ValTy, Alignment, AS, Ctx.CostKind, OpInfo, UI);
return ScalarMemOpCost + Ctx.TTI.getAddressComputationCost(
ScalarPtrTy, nullptr, nullptr, Ctx.CostKind);
}
// TODO: See getMemInstScalarizationCost for how to handle replicating and
// predicated cases.
break;
}
}

return Ctx.getLegacyCost(UI, VF);
Expand Down