[llvm] [AArch64][LV] Reduce cost of scaled reduction extends (PR #134074)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 05:48:48 PDT 2025
================
@@ -1796,6 +1796,11 @@ InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,
// For Z/Sext, get the context from the operand.
else if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt ||
Opcode == Instruction::FPExt) {
+ // If the extend is performed as part of another operation, it can be
+ // considered 'free'.
+ const VPlan *Plan = getParent()->getPlan();
+ if (Plan->isScaledReductionExtension(getUnderlyingInstr()))
+ return TargetTransformInfo::TCC_Free;
----------------
fhahn wrote:
If the extend is free then it should be modeled similar to other special reductions in https://github.com/llvm/llvm-project/pull/113903 as @davemgreen mentioned.
Recipes should encapsulate all information required to compute their costs. Otherwise we may have to spread logic to detect those free extends to multiple places (e.g. register pressure computation).
This should also make it easier to perform a specific TTI query, instead of encoding some target-dependent knowledge directly in ::computeCost
https://github.com/llvm/llvm-project/pull/134074
More information about the llvm-commits
mailing list