[Mlir-commits] [mlir] [mlir][ControlFlow] Improve time complexity of RegionBranchOpInterface canonicalization patterns (PR #186114)

Yang Bai llvmlistbot at llvm.org
Fri Mar 13 00:12:00 PDT 2026


================
@@ -668,6 +675,10 @@ static llvm::SmallDenseSet<Value> computeReachableValuesFromSuccessorInput(
     auto it = inputToOperands.find(next);
     if (it == inputToOperands.end()) {
       reachableValues.insert(next);
+      // Early exit: stop traversal if more reachable values than the caller
+      // cares about have been found.
+      if (maxReachableValues > 0 && reachableValues.size() > maxReachableValues)
+        return reachableValues;
----------------
yangtetris wrote:

You're right. The API contract was unclear.
The function now returns failure() when the limit is exceeded, making it explicit that the result set should not be used.

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


More information about the Mlir-commits mailing list