[Mlir-commits] [mlir] [mlir][bufferization] handle exit aliases in buffer-loop-hoisting (PR #226951)
Matteo Di Iorio
llvmlistbot at llvm.org
Sat Oct 3 07:41:57 PDT 2026
================
@@ -66,6 +69,50 @@ static bool isSequentialLoop(Operation *op) {
return !op->hasTrait<OpTrait::HasParallelRegion>() && isLoop(op);
}
+/// Returns true if an allocation can be reused across iterations when its
+/// aliases have a common dominator outside the while loop.
+/// `aliases` must contain the complete forward alias set of the allocation.
+static bool
+canHoistFromWhile(scf::WhileOp loop,
+ const BufferViewFlowAnalysis::ValueSetT &aliases) {
+ // Further hoisting across an enclosing loop with unmodeled parallel
+ // execution could share the allocation across iterations.
+ if (!isa<FunctionOpInterface>(loop->getParentOp()) ||
+ !loop->getParentOp()->hasTrait<OpTrait::IsIsolatedFromAbove>())
----------------
splicer3 wrote:
I kept this because `FunctionOpInterface` doesn’t imply isolation. However, hoisting before the while still leaves the allocation inside the function. For example in [`test.conversion_func_op`](https://github.com/llvm/llvm-project/blob/7516fa2ca8a47c15f5f31265f05c1157b56bb735/mlir/test/lib/Dialect/Test/TestOps.td#L752-L760), which isn’t isolated, the walk stops either at the target boundary or because the function doesn’t implement a control-flow interface recognized by the placement walk.
I think I can remove this check and keep the restriction to a while directly inside a function.
https://github.com/llvm/llvm-project/pull/226951
More information about the Mlir-commits
mailing list