[Mlir-commits] [mlir] ea294e3 - [MLIR][Affine] Make isValidLoopInterchangePermutation efficient (#128863)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Feb 26 07:13:54 PST 2025
Author: Arnab Dutta
Date: 2025-02-26T20:43:50+05:30
New Revision: ea294e3f1d3ca03a3a7e65a61d6b3945cc405200
URL: https://github.com/llvm/llvm-project/commit/ea294e3f1d3ca03a3a7e65a61d6b3945cc405200
DIFF: https://github.com/llvm/llvm-project/commit/ea294e3f1d3ca03a3a7e65a61d6b3945cc405200.diff
LOG: [MLIR][Affine] Make isValidLoopInterchangePermutation efficient (#128863)
Avoid doing dependency checks for the trivial case when size of `loops`
is 1.
Added:
Modified:
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
index 82b96e9876a6f..6833d6583c27a 100644
--- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
@@ -1351,10 +1351,12 @@ static bool checkLoopInterchangeDependences(
/// nested sequence of loops in 'loops' would violate dependences.
bool mlir::affine::isValidLoopInterchangePermutation(
ArrayRef<AffineForOp> loops, ArrayRef<unsigned> loopPermMap) {
+ assert(loopPermMap.size() == loops.size() && "invalid loop perm map");
+ unsigned maxLoopDepth = loops.size();
+ if (maxLoopDepth == 1)
+ return true;
// Gather dependence components for dependences between all ops in loop nest
// rooted at 'loops[0]', at loop depths in range [1, maxLoopDepth].
- assert(loopPermMap.size() == loops.size());
- unsigned maxLoopDepth = loops.size();
std::vector<SmallVector<DependenceComponent, 2>> depCompsVec;
getDependenceComponents(loops[0], maxLoopDepth, &depCompsVec);
return checkLoopInterchangeDependences(depCompsVec, loops, loopPermMap);
More information about the Mlir-commits
mailing list