[llvm] [AMDGPU] Enable sinking of free vector ops that will be folded into their uses (PR #162580)

Gheorghe-Teodor Bercea via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 24 11:25:01 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)))) {
----------------
doru1004 wrote:

This PR does more than just sink free vector ops. It since vector ops which can be folded into their uses. I amended the title to say that. Sorry for the misunderstanding.

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


More information about the llvm-commits mailing list