[llvm] [AMDGPU] A SCHED_BARRIER in a bundle should not prevent other SCHED_BARRIERs to be considered (PR #152627)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 13 16:52:21 PDT 2025


================
@@ -2502,13 +2502,18 @@ bool SchedGroup::canAddSU(SUnit &SU) const {
     return canAddMI(MI);
 
   // Special case for bundled MIs.
+  // Return true if all of the bundled MIs can be added to this group.
+  // A meta instruction in a bundle is an exception.
   const MachineBasicBlock *MBB = MI.getParent();
-  MachineBasicBlock::instr_iterator B = MI.getIterator(), E = ++B;
-  while (E != MBB->end() && E->isBundledWithPred())
-    ++E;
+  // Initially, iterator is on a bundler header.
+  MachineBasicBlock::instr_iterator B = std::next(MI.getIterator());
+  while (B != MBB->end() && B->isBundledWithPred()) {
+    if (!B->isMetaInstruction() && !canAddMI(*B))
----------------
arsenm wrote:

You also need to adjust the above usage in the unbundled case, but I meant make it not consider metainstructions at all (i.e. fully pull the meta instruction handling into this function here) 

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


More information about the llvm-commits mailing list