[llvm] [AMDGPU] Account for existing SDWA selections (PR #123221)

Frederik Harwath via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 01:05:55 PST 2025


================
@@ -1172,6 +1209,21 @@ bool SIPeepholeSDWA::convertToSDWA(MachineInstr &MI,
     SDWAInst->tieOperands(PreserveDstIdx, SDWAInst->getNumOperands() - 1);
   }
 
+  return SDWAInst.getInstr();
+}
+
+bool SIPeepholeSDWA::convertToSDWA(MachineInstr &MI,
+                                   const SDWAOperandsVector &SDWAOperands) {
+  LLVM_DEBUG(dbgs() << "Convert instruction:" << MI);
+
+  MachineInstr *SDWAInst;
+  if (TII->isSDWA(MI.getOpcode())) {
+    SDWAInst = MI.getParent()->getParent()->CloneMachineInstr(&MI);
+    MI.getParent()->insert(MI.getIterator(), SDWAInst);
+  } else {
+    SDWAInst = createSDWAVersion(MI);
----------------
frederik-h wrote:

The changes made to this function (i.e. extraction of `createSDWAVersion` and the inversion of the conditional statement below) are remainders of an earlier version of this PR and not essential. I would still suggest to keep them as I believe that they improve readability.

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


More information about the llvm-commits mailing list