[llvm] [SLP] Partially revert #224931 for alternate nodes (PR #228659)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 21:46:32 PDT 2026
https://github.com/hidekisaito created https://github.com/llvm/llvm-project/pull/228659
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.
>From 02ec228918252164bceee05b400515ddb9899bbd Mon Sep 17 00:00:00 2001
From: Hideki Saito <hidekido at amd.com>
Date: Sat, 3 Oct 2026 04:37:10 +0000
Subject: [PATCH] [SLP] Partially revert #224931 for alternate nodes
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.
---
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 516b4af4c4a528..a3725bd0dde7a0 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 &&
More information about the llvm-commits
mailing list