Skip to content

Commit ea294e3

Browse files
[MLIR][Affine] Make isValidLoopInterchangePermutation efficient (#128863)
Avoid doing dependency checks for the trivial case when size of `loops` is 1.
1 parent 35bf925 commit ea294e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,10 +1351,12 @@ static bool checkLoopInterchangeDependences(
13511351
/// nested sequence of loops in 'loops' would violate dependences.
13521352
bool mlir::affine::isValidLoopInterchangePermutation(
13531353
ArrayRef<AffineForOp> loops, ArrayRef<unsigned> loopPermMap) {
1354+
assert(loopPermMap.size() == loops.size() && "invalid loop perm map");
1355+
unsigned maxLoopDepth = loops.size();
1356+
if (maxLoopDepth == 1)
1357+
return true;
13541358
// Gather dependence components for dependences between all ops in loop nest
13551359
// rooted at 'loops[0]', at loop depths in range [1, maxLoopDepth].
1356-
assert(loopPermMap.size() == loops.size());
1357-
unsigned maxLoopDepth = loops.size();
13581360
std::vector<SmallVector<DependenceComponent, 2>> depCompsVec;
13591361
getDependenceComponents(loops[0], maxLoopDepth, &depCompsVec);
13601362
return checkLoopInterchangeDependences(depCompsVec, loops, loopPermMap);

0 commit comments

Comments
 (0)