[llvm] [AMDGPU] Account for existing SDWA selections (PR #123221)
Frederik Harwath via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 23 23:44:18 PST 2025
================
@@ -88,6 +88,42 @@ class SIPeepholeSDWALegacy : public MachineFunctionPass {
using namespace AMDGPU::SDWA;
+/// Check that the SDWA selections \p Sel and \p OperandSel
+/// are suitable for being combined by combineSdwaSel.
+bool compatibleSelections(SdwaSel Sel, SdwaSel OperandSel) {
+ return Sel == SdwaSel::DWORD || OperandSel == Sel ||
+ (Sel != SdwaSel::WORD_1 && Sel != SdwaSel::BYTE_2 &&
+ Sel != SdwaSel::BYTE_3 &&
+ (OperandSel == SdwaSel::WORD_0 || OperandSel == SdwaSel::WORD_1));
+}
+
+/// Combine an SDWA instruction's existing SDWA selection \p Sel with
+/// the SDWA selection \p OpSel of its operand which must be
+/// compatible.
+/// For example, if we have Sel = BYTE_0 Sel and OperandSel = WORD_1:
+/// BYTE_0 Sel (WORD_1 Sel (%X)) -> BYTE_2 Sel (%X)
+SdwaSel combineSdwaSel(SdwaSel Sel, SdwaSel OperandSel) {
----------------
frederik-h wrote:
I have now changed it to `static` and moved it out of the anonymous namespace as per the LLVM coding standards.
https://github.com/llvm/llvm-project/pull/123221
More information about the llvm-commits
mailing list