Skip to content

Commit

Permalink
[MLIR][Affine] Fix signature of mlir::affine::permuteLoops (#111100)
Browse files Browse the repository at this point in the history
The method doesn't mutate its argument. A mutable one was being passed
only to get around ArrayRef providing const on elements, which MLIR
doesn't use on IR types.
  • Loading branch information
bondhugula authored Nov 6, 2024
1 parent e48d8f9 commit d22d63a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/Affine/LoopUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool isValidLoopInterchangePermutation(ArrayRef<AffineForOp> loops,
/// to inner. Returns the position in `inputNest` of the AffineForOp that
/// becomes the new outermost loop of this nest. This method always succeeds,
/// asserts out on invalid input / specifications.
unsigned permuteLoops(MutableArrayRef<AffineForOp> inputNest,
unsigned permuteLoops(ArrayRef<AffineForOp> inputNest,
ArrayRef<unsigned> permMap);

// Sinks all sequential loops to the innermost levels (while preserving
Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ mlir::affine::isPerfectlyNested(ArrayRef<AffineForOp> loops) {

// input[i] should move from position i -> permMap[i]. Returns the position in
// `input` that becomes the new outermost loop.
unsigned mlir::affine::permuteLoops(MutableArrayRef<AffineForOp> input,
unsigned mlir::affine::permuteLoops(ArrayRef<AffineForOp> input,
ArrayRef<unsigned> permMap) {
assert(input.size() == permMap.size() && "invalid permutation map size");
// Check whether the permutation spec is valid. This is a small vector - we'll
Expand All @@ -1406,8 +1406,8 @@ unsigned mlir::affine::permuteLoops(MutableArrayRef<AffineForOp> input,
// Move the innermost loop body to the loop that would be the innermost in the
// permuted nest (only if the innermost loop is going to change).
if (permMap.back() != input.size() - 1) {
auto *destBody = input[invPermMap.back().second].getBody();
auto *srcBody = input.back().getBody();
Block *destBody = ((AffineForOp)input[invPermMap.back().second]).getBody();
Block *srcBody = ((AffineForOp)input.back()).getBody();
destBody->getOperations().splice(destBody->begin(),
srcBody->getOperations(), srcBody->begin(),
std::prev(srcBody->end()));
Expand Down Expand Up @@ -1437,7 +1437,7 @@ unsigned mlir::affine::permuteLoops(MutableArrayRef<AffineForOp> input,
continue;

// Move input[i] to its surrounding loop in the transformed nest.
auto *destBody = input[parentPosInInput].getBody();
auto *destBody = ((AffineForOp)input[parentPosInInput]).getBody();
destBody->getOperations().splice(destBody->begin(),
input[i]->getBlock()->getOperations(),
Block::iterator(input[i]));
Expand Down

0 comments on commit d22d63a

Please sign in to comment.