[Mlir-commits] [mlir] [flang][acc] Prune the acc.loop zero-trip edge when the body is proven to run (PR #219287)
Slava Zakharin
llvmlistbot at llvm.org
Thu Aug 27 15:53:58 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;
----------------
vzakhari wrote:
I suppose then we can report `Always` as in "the body is always entered". No need to change it in this PR, though,
https://github.com/llvm/llvm-project/pull/219287
More information about the Mlir-commits
mailing list