[Mlir-commits] [mlir] [MLIR] Support interrupting AffineExpr walks (PR #74792)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Fri Dec 8 01:27:38 PST 2023


================
@@ -186,8 +215,19 @@ class AffineExprVisitor : public AffineExprVisitorBase<SubClass, RetTy> {
 private:
   // Walk the operands - each operand is itself walked in post order.
   RetTy walkOperandsPostOrder(AffineBinaryOpExpr expr) {
-    walkPostOrder(expr.getLHS());
-    walkPostOrder(expr.getRHS());
+    if constexpr (std::is_same<RetTy, WalkResult>::value) {
+      if (walkPostOrder(expr.getLHS()).wasInterrupted())
+        return WalkResult::interrupt();
+    } else {
+      walkPostOrder(expr.getLHS());
+    }
+    if constexpr (std::is_same<RetTy, WalkResult>::value) {
+      if (walkPostOrder(expr.getLHS()).wasInterrupted())
+        return WalkResult::interrupt();
+      return WalkResult::advance();
+    } else {
----------------
ftynse wrote:

Nit: `else` is redundant after `return`. But I'd rather drop the `return` to make code more symmetric here.

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


More information about the Mlir-commits mailing list