Skip to content

Commit ffb73a7

Browse files
committed
replace equalIterationSpaces with checkFusionStructuredLegality
1 parent fbd7b72 commit ffb73a7

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

mlir/include/mlir/Dialect/SCF/Utils/Utils.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ void getPerfectlyNestedLoops(SmallVectorImpl<scf::ForOp> &nestedLoops,
160160
// Fusion related helpers
161161
//===----------------------------------------------------------------------===//
162162

163-
bool checkFusionStructuralLegality(LoopLikeOpInterface &target,
164-
LoopLikeOpInterface &source);
163+
/// Check structural compatibility between two loops such as iteration space.
164+
bool checkFusionStructuralLegality(LoopLikeOpInterface target,
165+
LoopLikeOpInterface source);
165166

166167
/// Given two scf.forall loops, `target` and `source`, fuses `target` into
167168
/// `source`. Assumes that the given loops are siblings and are independent of

mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ static bool hasNestedParallelOp(ParallelOp ploop) {
3838
return walkResult.wasInterrupted();
3939
}
4040

41-
/// Verify equal iteration spaces.
42-
static bool equalIterationSpaces(ParallelOp firstPloop,
43-
ParallelOp secondPloop) {
44-
if (firstPloop.getNumLoops() != secondPloop.getNumLoops())
45-
return false;
46-
47-
auto matchOperands = [&](const OperandRange &lhs,
48-
const OperandRange &rhs) -> bool {
49-
// TODO: Extend this to support aliases and equal constants.
50-
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
51-
};
52-
return matchOperands(firstPloop.getLowerBound(),
53-
secondPloop.getLowerBound()) &&
54-
matchOperands(firstPloop.getUpperBound(),
55-
secondPloop.getUpperBound()) &&
56-
matchOperands(firstPloop.getStep(), secondPloop.getStep());
57-
}
58-
5941
/// Checks if the parallel loops have mixed access to the same buffers. Returns
6042
/// `true` if the first parallel loop writes to the same indices that the second
6143
/// loop reads.
@@ -156,7 +138,7 @@ static bool isFusionLegal(ParallelOp firstPloop, ParallelOp secondPloop,
156138
llvm::function_ref<bool(Value, Value)> mayAlias) {
157139
return !hasNestedParallelOp(firstPloop) &&
158140
!hasNestedParallelOp(secondPloop) &&
159-
equalIterationSpaces(firstPloop, secondPloop) &&
141+
checkFusionStructuralLegality(firstPloop, secondPloop) &&
160142
succeeded(verifyDependencies(firstPloop, secondPloop,
161143
firstToSecondPloopIndices, mayAlias));
162144
}

mlir/lib/Dialect/SCF/Utils/Utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,8 @@ TileLoops mlir::extractFixedOuterLoops(scf::ForOp rootForOp,
10741074
// Fusion related helpers
10751075
//===----------------------------------------------------------------------===//
10761076

1077-
bool mlir::checkFusionStructuralLegality(LoopLikeOpInterface &target,
1078-
LoopLikeOpInterface &source) {
1077+
bool mlir::checkFusionStructuralLegality(LoopLikeOpInterface target,
1078+
LoopLikeOpInterface source) {
10791079
bool iterSpaceEq =
10801080
target.getLoopLowerBounds() == source.getLoopLowerBounds() &&
10811081
target.getLoopUpperBounds() == source.getLoopUpperBounds() &&

0 commit comments

Comments
 (0)