[llvm] [Uniformity] Fixed control-div early stop (PR #139667)

Junjie Gu via llvm-commits llvm-commits at lists.llvm.org
Mon May 26 09:44:47 PDT 2025


================
@@ -626,14 +623,36 @@ template <typename ContextT> class DivergencePropagator {
         LLVM_DEBUG(dbgs() << "\tImmediate divergent cycle exit: "
                           << Context.print(SuccBlock) << "\n");
       }
-      auto SuccIdx = CyclePOT.getIndex(SuccBlock);
       visitEdge(*SuccBlock, *SuccBlock);
-      FloorIdx = std::min<int>(FloorIdx, SuccIdx);
     }
 
+    // Return true if B is inside an irreducible cycle
+    auto IsInIrreducibleCycle = [this](const BlockT *B) {
+      for (const auto *Cycle = CI.getCycle(B); Cycle;
+           Cycle = Cycle->getParentCycle()) {
+        if (!Cycle->isReducible())
+          return true;
----------------
jgu222 wrote:

The algo may be conservative for some irreducible CFGs,  but it should be correct based on our convergence assumption.  I agree we need a formal proof. 

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


More information about the llvm-commits mailing list