[llvm] [AMDGPU][FixIrreducible][UnifyLoopExits] Support callbr with inline-asm (PR #149308)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 20 23:19:09 PDT 2025


================
@@ -186,11 +218,17 @@ static bool unifyLoopExits(DominatorTree &DT, LoopInfo &LI, Loop *L) {
   L->verifyLoop();
 
   // The guard blocks were created outside the loop, so they need to become
-  // members of the parent loop.
+  // members of the parent loop. Same goes for the callbr target blocks if they
+  // have not already been added to the respective parent loop by adding them to
+  // the original callbr target's loop.
   if (auto ParentLoop = L->getParentLoop()) {
     for (auto *G : GuardBlocks) {
       ParentLoop->addBasicBlockToLoop(G, LI);
     }
+    for (auto *C : CallBrTargetBlocks) {
+      if (!ParentLoop->contains(C))
+        ParentLoop->addBasicBlockToLoop(C, LI);
----------------
ssahasra wrote:

We could get this information from `ControlFlowHub::createCallBrTarget()` since that function knows if we updated `LI` or not.

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


More information about the llvm-commits mailing list