[Mlir-commits] [flang] [mlir] [MLIR][CF] Avoid collapsing blocks which participate in cycles (PR #160783)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 29 01:34:21 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.
+ BranchOp nextBranch = dyn_cast<BranchOp>(successorDest->getTerminator());
+ llvm::DenseSet<Block *> visited{successorDest};
+ while (nextBranch) {
+ Block *nextBranchDest = nextBranch.getDest();
+ if (nextBranchDest == successor)
+ return failure();
+ else if (visited.contains(nextBranchDest))
+ break;
----------------
benwu25 wrote:
Ok, I have pushed again the changes to bail out early, as well as updated the `flang` test. @matthias-springer could you merge these changes for me if they are now acceptable? Thanks!
https://github.com/llvm/llvm-project/pull/160783
More information about the Mlir-commits
mailing list