[Mlir-commits] [mlir] [flang][acc] Prune the acc.loop zero-trip edge when the body is proven to run (PR #219287)
Razvan Lupusoru
llvmlistbot at llvm.org
Thu Aug 27 19:18:25 PDT 2026
================
@@ -593,6 +594,67 @@ ValueRange HostDataOp::getSuccessorInputs(RegionSuccessor successor) {
return getSingleRegionSuccessorInputs(getOperation(), successor);
}
+/// Whether the body of a structured `acc.loop` is proven to run. This decides
+/// which edges out of the parent are feasible; the edges out of the region are
+/// unaffected.
+enum class BodyExecution {
+ /// The body runs at least once, so the parent cannot bypass the region.
+ Always,
+ /// The body never runs, so the parent cannot enter the region.
+ Never,
+ /// Neither could be proven, so the parent may do either.
+ Maybe
+};
+
+/// Prove whether the body of `loopOp` runs. A counted dimension whose entry
+/// test already fails at its lower bound runs exactly zero times, so a single
+/// comparison decides both `Always` and `Never`. Bounds that are not constant
+/// prove nothing.
+static BodyExecution getBodyExecution(LoopOp loopOp) {
+ // A container-like loop describes its iteration space inside the region.
+ if (loopOp.isContainerLike())
+ return BodyExecution::Maybe;
----------------
razvanlupusoru wrote:
`Maybe` seems more reasonable to me because I view the `acc.loop` that is container-like simply as a wrapper to not lose acc related metadata which at some point goes away. This means that the body of the container likely has some sort of loop whose "body" may or may not be entered.
https://github.com/llvm/llvm-project/pull/219287
More information about the Mlir-commits
mailing list