[Mlir-commits] [mlir] [mlir][bufferization] Relax happens-before analysis for unstructured CF (PR #223006)
Colin De Vlieghere
llvmlistbot at llvm.org
Mon Sep 14 10:59:03 PDT 2026
Cubevoid wrote:
> > * this check also tries to take into account simple loops in the CFG using the CFGLoopInfo analysis. Notably if you have a parent loop containing multiple blocks, back-edges through the parent's header block are ignored for the reachability condition.
>
> What's the use case for this? MLIR has structured control flow to make these kind of analyses easier. Are you lowering SCF->CF too early in your compilation pipeline?
Yes indeed, I am lowering SCF to CF before bufferization. You are right that SCF is definitely easier to analyze (the existing dominance check is enough), and I would much prefer bufferizing SCF instead if not for other application-specific reasons why it does not make sense for me to do that. I recognize that this patch does not provide a perfect analysis of unstructured CF, but the hope is that it is good enough to recognize the common cases (e.g. loops, if statements) without making the analysis _too_ complicated.
If you are apprehensive about the CFGLoopInfo addition, I am happy to first submit a simpler patch where it just checks reachability without considering parent loops. This would still be too conservative as it would consider a back-edge from a parent loop to be a conflict, but it should at least work for regions without nesting like that.
https://github.com/llvm/llvm-project/pull/223006
More information about the Mlir-commits
mailing list