[llvm] [AMDGPU] Hoist WMMA coexecution hazard V_NOPs from loops to preheaders (PR #176895)

Dark Steve via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 09:13:11 PST 2026


================
@@ -49,6 +52,12 @@ class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
   const SIInstrInfo &TII;
   const SIRegisterInfo &TRI;
   const TargetSchedModel &TSchedModel;
+
+  // Loop info for V_NOP hoisting, computed on demand only when needed.
+  std::unique_ptr<MachineDominatorTree> OwnedMDT;
+  std::unique_ptr<MachineLoopInfo> OwnedMLI;
+  MachineLoopInfo *MLI = nullptr;
----------------
PrasoonMishra wrote:

`post-RA-hazard-rec` doesn't compute or request loop information. 

Looking at the passes that run just before it in our default pipeline:
```
SI Final Branch Preparation
SI peephole optimizations  
Post RA hazard recognizer
```
SI Final Branch Preparation (SILateBranchLowering) modifies CFG without preserving MLI. So even if MLI was available earlier,  it would be invalid by the time we reach `post-RA-hazard-rec`.

I considered adding MLI as a required analysis for PostRAHazardRecognizer, but since it's a target-independent pass, that would add the dependency for all backends. The lazy computation keeps this AMDGPU-specific.

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


More information about the llvm-commits mailing list