[llvm] [SLP] Partially revert #224931 for alternate nodes (PR #228659)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 21:47:09 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-vectorizers

Author: hidekisaito

<details>
<summary>Changes</summary>

Do not pass scalar context to alternate node vector cost queries.

costing the vector ops of an alternate node. Those vector ops only feed the lane-select shuffle, so use-based discounts derived from the scalar's users do not apply. On AMDGPU this priced an [fmul | fadd] node's vector fmul as fused (free) where the sole user of the scalar fmul is fadd/fsub, keeping unprofitable subtrees vectorized. In a rocFFT kernel on gfx950 this raised VGPR usage from 160 to 178 and caused a performance regression. Restore the null context for these queries.

---
Full diff: https://github.com/llvm/llvm-project/pull/228659.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+1-2) 


``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 516b4af4c4a52..a3725bd0dde7a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -17910,8 +17910,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
             if (!RunningInfo.isConstant() || !ColInfo.isConstant())
               Cost += TTIRef.getArithmeticInstrCost(
                   Opcode, VecTy, CostKind, RunningInfo, ColInfo, {},
-                  Opcode == E->getOpcode() ? E->getMainOp() : E->getAltOp(),
-                  TLI);
+                  /*CxtI=*/nullptr, TLI);
             TTI::OperandValueKind Kind = TTI::OK_AnyValue;
             if (RunningInfo.isConstant() && ColInfo.isConstant())
               Kind = RunningInfo.Kind == TTI::OK_UniformConstantValue &&

``````````

</details>


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


More information about the llvm-commits mailing list