[llvm] [SLP] Only veto vectorization for an fma worth more than the wide loads (PR #218755)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 07:19:12 PDT 2026
================
@@ -13845,7 +13845,47 @@ static InstructionCost canConvertToFMA(ArrayRef<Value *> VL,
DominatorTree &DT, const DataLayout &DL,
TargetTransformInfo &TTI,
const TargetLibraryInfo &TLI,
- const TTI::TargetCostKind CostKind);
+ const TTI::TargetCostKind CostKind,
+ InstructionCost *UnfusedCost = nullptr);
+
+/// \returns true if contracting \p FMul into an fma with its user is worth
+/// more than the wide loads a vector node over the multiplication would
+/// fold its operands into. \p FMACost and \p UnfusedCost are what
+/// canConvertToFMA measured for the scalar pair, so the saving the veto buys
+/// is the difference between them.
+static bool preferFMAOverVectorNode(const Value *FMul, InstructionCost FMACost,
+ InstructionCost UnfusedCost,
+ const TargetTransformInfo &TTI,
+ TTI::TargetCostKind CostKind) {
+ const auto *FMulI = dyn_cast<Instruction>(FMul);
+ if (!FMulI)
+ return true;
+ Type *ScalarTy = FMulI->getType();
----------------
alexey-bataev wrote:
```suggestion
assert(FMulI->getOpcode() == Instruction::FMul &&
"expected the multiplication operand of the fma candidate");
Type *ScalarTy = FMulI->getType();
```
https://github.com/llvm/llvm-project/pull/218755
More information about the llvm-commits
mailing list