[Mlir-commits] [mlir] [MLIR][NFC] Speed up is valid symbol check (PR #154924)
William Moses
llvmlistbot at llvm.org
Fri Aug 22 03:47:36 PDT 2025
https://github.com/wsmoses created https://github.com/llvm/llvm-project/pull/154924
This adds an early exit condition, and removes the closure indirection, potentially enabling tail recursion elim, etc.
>From c772acf3269f842a2a72cbba446f23c1c78dcd5e Mon Sep 17 00:00:00 2001
From: "William S. Moses" <gh at wsmoses.com>
Date: Fri, 22 Aug 2025 05:46:29 -0500
Subject: [PATCH] [MLIR][NFC] Speed up is valid symbol check
---
mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 22608a16cc1ab..53538d9c01428 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -465,10 +465,16 @@ bool mlir::affine::isValidSymbol(Value value, Region *region) {
return true;
// `Pure` operation that whose operands are valid symbolic identifiers.
- if (isPure(defOp) && llvm::all_of(defOp->getOperands(), [&](Value operand) {
- return affine::isValidSymbol(operand, region);
- })) {
- return true;
+ if (isPure(defOp)) {
+ bool allValid = true;
+ for (auto operand : defOp->getOperands()) {
+ if (!affine::isValidSymbol(operand, region)) {
+ allValid = false;
+ break;
+ }
+ }
+ if (allValid)
+ return true;
}
// Dim op results could be valid symbols at any level.
More information about the Mlir-commits
mailing list