From d22d63a7855840dd6398b77dcad71f001788ac86 Mon Sep 17 00:00:00 2001 From: Uday Bondhugula Date: Wed, 6 Nov 2024 09:42:01 +0530 Subject: [PATCH] [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. --- mlir/include/mlir/Dialect/Affine/LoopUtils.h | 2 +- mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mlir/include/mlir/Dialect/Affine/LoopUtils.h b/mlir/include/mlir/Dialect/Affine/LoopUtils.h index 99c500c7dd6452..380c742b5224cb 100644 --- a/mlir/include/mlir/Dialect/Affine/LoopUtils.h +++ b/mlir/include/mlir/Dialect/Affine/LoopUtils.h @@ -136,7 +136,7 @@ bool isValidLoopInterchangePermutation(ArrayRef 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 inputNest, +unsigned permuteLoops(ArrayRef inputNest, ArrayRef permMap); // Sinks all sequential loops to the innermost levels (while preserving diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp index 150b9824c41e30..d6fc4ed07bfab3 100644 --- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp @@ -1379,7 +1379,7 @@ mlir::affine::isPerfectlyNested(ArrayRef 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 input, +unsigned mlir::affine::permuteLoops(ArrayRef input, ArrayRef permMap) { assert(input.size() == permMap.size() && "invalid permutation map size"); // Check whether the permutation spec is valid. This is a small vector - we'll @@ -1406,8 +1406,8 @@ unsigned mlir::affine::permuteLoops(MutableArrayRef 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())); @@ -1437,7 +1437,7 @@ unsigned mlir::affine::permuteLoops(MutableArrayRef 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]));