Skip to content

Commit 04b17bd

Browse files
authored
[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.
1 parent 0bb1e04 commit 04b17bd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,11 +1926,13 @@ void ForallOp::getCanonicalizationPatterns(RewritePatternSet &results,
19261926
/// not a constant.
19271927
void ForallOp::getSuccessorRegions(RegionBranchPoint point,
19281928
SmallVectorImpl<RegionSuccessor> &regions) {
1929-
// Both the operation itself and the region may be branching into the body or
1930-
// back into the operation itself. It is possible for loop not to enter the
1931-
// body.
1932-
regions.push_back(RegionSuccessor(&getRegion()));
1933-
regions.push_back(RegionSuccessor());
1929+
// In accordance with the semantics of forall, its body is executed in
1930+
// parallel by multiple threads. We should not expect to branch back into
1931+
// the forall body after the region's execution is complete.
1932+
if (point.isParent())
1933+
regions.push_back(RegionSuccessor(&getRegion()));
1934+
else
1935+
regions.push_back(RegionSuccessor());
19341936
}
19351937

19361938
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)