[llvm] [AMDGPU] Skip processing some uses in fixVALUMaskWriteHazard (NFC) (PR #198852)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 02:23:22 PDT 2026


================
@@ -3452,36 +3464,27 @@ bool GCNHazardRecognizer::fixVALUMaskWriteHazard(MachineInstr *MI) {
   bool HasSGPRRead = false;
   StateType InitialState;
 
-  // Look for SGPR write.
+  // Look for SGPR writes first, so we can we can bail out early if none.
   MachineOperand *HazardDef = nullptr;
   for (MachineOperand &Op : MI->operands()) {
-    if (!Op.isReg())
-      continue;
-    if (Op.isDef() && HazardDef)
-      continue;
-
-    Register Reg = Op.getReg();
-    if (IgnoreableSGPR(Reg))
-      continue;
-    if (!IsVCC(Reg)) {
-      if (Op.isImplicit())
-        continue;
-      if (!TRI->isSGPRReg(MRI, Reg))
-        continue;
-    }
-    // Also check for SGPR reads.
-    if (Op.isUse()) {
-      HasSGPRRead = true;
+    if (!Op.isReg() || !Op.isDef() || !IsRelevantSGPR(Op))
       continue;
-    }
-
     assert(!HazardDef);
     HazardDef = &Op;
+    break;
   }
 
   if (!HazardDef)
     return false;
 
+  // Then check for SGPR reads.
+  for (MachineOperand &Op : MI->operands()) {
----------------
jayfoad wrote:

Use `MI->all_uses()`?

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


More information about the llvm-commits mailing list