[Mlir-commits] [mlir] 04b17bd - [mlir][scf] fix getSuccessorRegions func in scf.forall (#147491)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jul 20 18:27:41 PDT 2025
Author: donald chen
Date: 2025-07-21T09:27:37+08:00
New Revision: 04b17bd47086b54e6b618d48aca3a6b54773fabf
URL: https://github.com/llvm/llvm-project/commit/04b17bd47086b54e6b618d48aca3a6b54773fabf
DIFF: https://github.com/llvm/llvm-project/commit/04b17bd47086b54e6b618d48aca3a6b54773fabf.diff
LOG: [mlir][scf] fix getSuccessorRegions func in scf.forall (#147491)
In accordance with the semantics of forall, its body is executed in
parallel by multiple threads. We should not expect to branch back into
the forall body after the region's execution is complete.
Added:
Modified:
mlir/lib/Dialect/SCF/IR/SCF.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 00c31a1500e17..df41eba4ef533 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -1926,11 +1926,13 @@ void ForallOp::getCanonicalizationPatterns(RewritePatternSet &results,
/// not a constant.
void ForallOp::getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> ®ions) {
- // Both the operation itself and the region may be branching into the body or
- // back into the operation itself. It is possible for loop not to enter the
- // body.
- regions.push_back(RegionSuccessor(&getRegion()));
- regions.push_back(RegionSuccessor());
+ // In accordance with the semantics of forall, its body is executed in
+ // parallel by multiple threads. We should not expect to branch back into
+ // the forall body after the region's execution is complete.
+ if (point.isParent())
+ regions.push_back(RegionSuccessor(&getRegion()));
+ else
+ regions.push_back(RegionSuccessor());
}
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list