Skip to content

Commit d22d63a

Browse files
authored
[MLIR][Affine] Fix signature of mlir::affine::permuteLoops (#111100)
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.
1 parent e48d8f9 commit d22d63a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mlir/include/mlir/Dialect/Affine/LoopUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool isValidLoopInterchangePermutation(ArrayRef<AffineForOp> loops,
136136
/// to inner. Returns the position in `inputNest` of the AffineForOp that
137137
/// becomes the new outermost loop of this nest. This method always succeeds,
138138
/// asserts out on invalid input / specifications.
139-
unsigned permuteLoops(MutableArrayRef<AffineForOp> inputNest,
139+
unsigned permuteLoops(ArrayRef<AffineForOp> inputNest,
140140
ArrayRef<unsigned> permMap);
141141

142142
// Sinks all sequential loops to the innermost levels (while preserving

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ mlir::affine::isPerfectlyNested(ArrayRef<AffineForOp> loops) {
13791379

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

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

0 commit comments

Comments
 (0)