[llvm] [AMDGPU] Allow sinking of free vector ops (PR #109172)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 23:18:58 PDT 2024


================
@@ -6010,8 +6010,94 @@ bool AMDGPUTargetLowering::shouldSinkOperands(
     if (any_of(Ops, [&](Use *U) { return U->get() == Op.get(); }))
       continue;
 
+    // This helps using several modifiers (abs and neg) more often.
     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.
+    DataLayout DL = I->getModule()->getDataLayout();
----------------
arsenm wrote:

const ref, DataLayout should never be copied 

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


More information about the llvm-commits mailing list