[Mlir-commits] [mlir] [MLIR][CF] Avoid collapsing blocks which participate in cycles (PR #160783)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Sep 26 14:01:04 PDT 2025


================
@@ -122,6 +122,18 @@ static LogicalResult collapseBranch(Block *&successor,
   Block *successorDest = successorBranch.getDest();
   if (successorDest == successor)
     return failure();
+  // Don't try to collapse branches which participate in a cycle.
+  Block *currBlock = successorDest;
+  BranchOp nextBranch = dyn_cast<BranchOp>(currBlock->getTerminator());
+  while (nextBranch) {
----------------
benwu25 wrote:

Yes, I think a `DenseSet` will be the right tool here. I have added changes to employ one for cycle detection.

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


More information about the Mlir-commits mailing list