[Mlir-commits] [mlir] [MLIR][NFC] Speed up is valid symbol check (PR #154924)

William Moses llvmlistbot at llvm.org
Fri Aug 22 04:20:15 PDT 2025


================
@@ -465,22 +478,22 @@ 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;
----------------
wsmoses wrote:

I essentially inlined the llvm:all_of. So specifically it checks each operand if it is valid, and if any is not valid, doesn't return true. In addition to inlining (and thus not capturing/etc), there's an early break if it is known not valid. llvm::all_of forwards to std::all_of, which I don't know if is required to have an early break vs always iterate the entire range.

https://github.com/llvm/llvm-project/pull/154924


More information about the Mlir-commits mailing list