[Mlir-commits] [mlir] [mlir] added a check in the walk to prevent catching a cos in a nested region (PR #190064)

Slava Zakharin llvmlistbot at llvm.org
Wed Apr 1 19:03:15 PDT 2026


================
@@ -27,13 +27,13 @@ struct SincosFusionPattern : OpRewritePattern<math::SinOp> {
     mlir::arith::FastMathFlags sinFastMathFlags = sinOp.getFastmath();
 
     math::CosOp cosOp = nullptr;
-    sinOp->getBlock()->walk([&](math::CosOp op) {
+    for (auto op : sinOp->getBlock()->getOps<math::CosOp>()) {
       if (op.getOperand() == operand && op.getFastmath() == sinFastMathFlags) {
         cosOp = op;
         return WalkResult::interrupt();
       }
       return WalkResult::advance();
-    });
+    }
----------------
vzakhari wrote:

Please remove braces for the for loop. Otherwise, looks good.

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


More information about the Mlir-commits mailing list