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

William Moses llvmlistbot at llvm.org
Fri Aug 22 04:27:21 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:

so per https://en.cppreference.com/w/cpp/algorithm/all_any_none_of.html it looks like it's up to the stdc++ implementation. Which means that the existing llvm::all_of does not guarantee to early exit, whereas this does.

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


More information about the Mlir-commits mailing list