Skip to content

Commit 88d6a59

Browse files
author
git apple-llvm automerger
committed
Merge commit '04b17bd47086' from llvm.org/main into next
2 parents e298c8c + 04b17bd commit 88d6a59

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)