[llvm] [AMDGPU] Allow sinking of free vector ops (PR #162580)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 24 08:30:16 PDT 2025
================
@@ -1301,6 +1301,87 @@ bool GCNTTIImpl::isProfitableToSinkOperands(Instruction *I,
if (match(&Op, m_FAbs(m_Value())) || match(&Op, m_FNeg(m_Value())))
Ops.push_back(&Op);
+
+ // Zero cost vector instructions (e.g. extractelement 0 of i32 vectors)
+ // will be optimized away, and sinking them can help SDAG combines.
+ const DataLayout &DL = I->getModule()->getDataLayout();
+
+ uint64_t VecIndex;
+ Value *Vec;
+ if (match(Op.get(), m_ExtractElt(m_Value(Vec), m_ConstantInt(VecIndex)))) {
----------------
arsenm wrote:
This all looks like too much code trying to re-invent what the general cost function is doing. You're parsing out all of the vector cases, can't you just query if the cost is free? And maybe if any operand is a vector type?
https://github.com/llvm/llvm-project/pull/162580
More information about the llvm-commits
mailing list