[llvm] [AMDGPU] Adding multiple use analysis to SIPeepholeSDWA (PR #94800)

Brian Favela via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 13:55:27 PDT 2024


================
@@ -327,7 +336,37 @@ uint64_t SDWASrcOperand::getSrcMods(const SIInstrInfo *TII,
   return Mods;
 }
 
-MachineInstr *SDWASrcOperand::potentialToConvert(const SIInstrInfo *TII) {
+MachineInstr *SDWASrcOperand::potentialToConvert(const SIInstrInfo *TII,
+                                                 const GCNSubtarget &ST,
+                                                 SDWAOperandsMap *PotentialMatches) {
+  // If PotentialMatches is not null, then fill out the map for all uses,
+  // if all can be converted
+  if (PotentialMatches != nullptr) {
+    MachineOperand *Reg = getReplacedOperand();
+    if (!Reg->isReg() || !Reg->isDef()) {
+      return nullptr;
+    }
+
+    for (MachineOperand &UseMO : getMRI()->use_nodbg_operands(Reg->getReg())) {
----------------
bfavela wrote:

I iterated on operands because of the subreg issue. Otherwise we may inadvertently mark an operand as foldable. I do observe that we should never get one, though, as "matchSDWAOperands" shouldn't allow it to happen. I can add an assert into the next loop and convert this to instructions.

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


More information about the llvm-commits mailing list