[llvm] [Uniformity] Fixed control-div early stop (PR #139667)
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Sun May 25 23:03:21 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;
----------------
ssahasra wrote:
"All tests passed" is not a sufficient criterion for deciding that this heuristic actually works. I do believe that this is a sufficient work around for now, but a formal proof is pending. Let's go with this for now, but separately we still need to prove it beyond all doubt.
Also, in its current state, it may cause unnecessary traversal when the current block is in an irreducible cycle that does not contain `DivTermBlock`, and it is reachable only after the IPD of `DivTermBlock`. But this is rare and performance issue rather than a correctness issue.
https://github.com/llvm/llvm-project/pull/139667
More information about the llvm-commits
mailing list