[llvm] a63eace - [VPlan] Don't use Ingredient to get type in VPWidenMemoryRecipe (NFC) (#200049)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 01:59:28 PDT 2026
Author: Florian Hahn
Date: 2026-05-28T08:59:22Z
New Revision: a63eacee2db2c6ea75c67aca729cc3d32426200b
URL: https://github.com/llvm/llvm-project/commit/a63eacee2db2c6ea75c67aca729cc3d32426200b
DIFF: https://github.com/llvm/llvm-project/commit/a63eacee2db2c6ea75c67aca729cc3d32426200b.diff
LOG: [VPlan] Don't use Ingredient to get type in VPWidenMemoryRecipe (NFC) (#200049)
The scalar load/store type is already available on the recipe: load
recipes inherit from VPSingleDefRecipe and expose it via
getScalarType(); store recipes can derive it from the stored value's
type via VPTypeAnalysis.
This migrates a number of lookups to be based on information already
available in VPlan directly.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index c655eae381397..9ebc98f08ddb8 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3857,12 +3857,13 @@ void VPPredInstPHIRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
VPCostContext &Ctx) const {
const VPRecipeBase *R = getAsRecipe();
- Type *Ty = toVectorTy(getLoadStoreType(&Ingredient), VF);
+ bool IsLoad = isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(R);
+ Type *ScalarTy = IsLoad ? cast<VPSingleDefRecipe>(R)->getScalarType()
+ : Ctx.Types.inferScalarType(R->getOperand(1));
+ Type *Ty = toVectorTy(ScalarTy, VF);
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
->getAddressSpace();
- unsigned Opcode = isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(R)
- ? Instruction::Load
- : Instruction::Store;
+ unsigned Opcode = IsLoad ? Instruction::Load : Instruction::Store;
if (!Consecutive) {
// TODO: Using the original IR may not be accurate.
@@ -3880,8 +3881,8 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
};
assert(!IsReverseMask() &&
"Inconsecutive memory access should not have reverse order");
- const Value *Ptr = getLoadStorePointerOperand(&Ingredient);
- Type *PtrTy = Ptr->getType();
+ Type *PtrTy = Ctx.Types.inferScalarType(getAddr());
+ const Value *Ptr = getAddr()->getUnderlyingValue();
// If the address value is uniform across all lanes, then the address can be
// calculated with scalar type and broadcast.
@@ -3917,7 +3918,7 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
}
void VPWidenLoadRecipe::execute(VPTransformState &State) {
- Type *ScalarDataTy = getLoadStoreType(&Ingredient);
+ Type *ScalarDataTy = getScalarType();
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
bool CreateGather = !isConsecutive();
@@ -3953,7 +3954,7 @@ void VPWidenLoadRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
#endif
void VPWidenLoadEVLRecipe::execute(VPTransformState &State) {
- Type *ScalarDataTy = getLoadStoreType(&Ingredient);
+ Type *ScalarDataTy = getScalarType();
auto *DataTy = VectorType::get(ScalarDataTy, State.VF);
bool CreateGather = !isConsecutive();
@@ -3992,7 +3993,7 @@ InstructionCost VPWidenLoadEVLRecipe::computeCost(ElementCount VF,
// legacy model, it will always calculate the cost of mask.
// TODO: Using getMemoryOpCost() instead of getMemIntrinsicInstrCost when we
// don't need to compare to the legacy cost model.
- Type *Ty = toVectorTy(getLoadStoreType(&Ingredient), VF);
+ Type *Ty = toVectorTy(getScalarType(), VF);
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
->getAddressSpace();
return Ctx.TTI.getMemIntrinsicInstrCost(
@@ -4080,7 +4081,7 @@ InstructionCost VPWidenStoreEVLRecipe::computeCost(ElementCount VF,
// legacy model, it will always calculate the cost of mask.
// TODO: Using getMemoryOpCost() instead of getMemIntrinsicInstrCost when we
// don't need to compare to the legacy cost model.
- Type *Ty = toVectorTy(getLoadStoreType(&Ingredient), VF);
+ Type *Ty = toVectorTy(Ctx.Types.inferScalarType(getStoredValue()), VF);
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
->getAddressSpace();
return Ctx.TTI.getMemIntrinsicInstrCost(
More information about the llvm-commits
mailing list