diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index 4ac86561b4f2..7e5ce26b5f73 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -473,16 +473,10 @@ bool mlir::affine::isValidSymbol(Value value, Region *region) { return true; // `Pure` operation that whose operands are valid symbolic identifiers. - if (isPure(defOp)) { - bool allValid = true; - for (auto operand : defOp->getOperands()) { - if (!affine::isValidSymbol(operand, region)) { - allValid = false; - break; - } - } - if (allValid) - return true; + if (isPure(defOp) && llvm::all_of(defOp->getOperands(), [&](Value operand) { + return affine::isValidSymbol(operand, region); + })) { + return true; } // Dim op results could be valid symbols at any level.