[Mlir-commits] [mlir] Make isValidLoopInterchangePermutation efficient (PR #128863)
Arnab Dutta
llvmlistbot at llvm.org
Wed Feb 26 03:21:02 PST 2025
https://github.com/arnab-polymage updated https://github.com/llvm/llvm-project/pull/128863
>From aa77f17b025fee9df84b2eb5aaf03508261d23f9 Mon Sep 17 00:00:00 2001
From: Arnab Dutta <arnab at polymagelabs.com>
Date: Fri, 18 Oct 2024 11:01:34 +0530
Subject: [PATCH] Make isValidLoopInterchangePermutation efficient
Avoid doing dependency checks for the trivial case when
size of `loops` is 1.
---
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
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