[llvm] [Uniformity] Fixed control-div early stop (PR #139667)
Junjie Gu via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 21:46:46 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:
> I have not tested this thoroughly yet, but I believe we can stop early if we reach a reducible cycle that contains both the `DivTermBlock` and the current block. This ensures that we don't end up unnecessarily traversing a large cycle like in this situation:
>
I updated the patch based on your suggestion. All tests passed for me.
https://github.com/llvm/llvm-project/pull/139667
More information about the llvm-commits
mailing list