[llvm-branch-commits] [llvm] [TTI][SLP] Pass the scalars of the lanes to getArithmeticInstrCost (PR #241758)

Alexey Bataev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Nov 21 13:57:05 PST 2026


================
@@ -18462,11 +18464,17 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
           for (unsigned Idx : seq<unsigned>(1, E->getNumOperands())) {
             TTI::OperandValueInfo ColInfo =
                 TTI::getOperandInfo(E->getOperand(Idx));
-            if (!RunningInfo.isConstant() || !ColInfo.isConstant())
+            if (!RunningInfo.isConstant() || !ColInfo.isConstant()) {
+              bool IsFinal = Idx + 1 == E->getNumOperands();
               Cost += TTIRef.getArithmeticInstrCost(
                   Opcode, VecTy, CostKind, RunningInfo, ColInfo, {},
-                  Opcode == E->getOpcode() ? E->getMainOp() : E->getAltOp(),
-                  TLI);
+                  IsFinal ? (Opcode == E->getOpcode() ? E->getMainOp()
+                                                      : E->getAltOp())
+                          : nullptr,
+                  TLI,
+                  IsFinal ? ArrayRef<const Value *>(E->Scalars)
+                          : ArrayRef<const Value *>{});
----------------
alexey-bataev wrote:

Why empty list? No, not an SLP call, TTI must do it, if you need it

https://github.com/llvm/llvm-project/pull/241758


More information about the llvm-branch-commits mailing list