[Mlir-commits] [mlir] [mlir][linalg-transform] dyn_cast DestinationStyleOpInterface and early return (PR #166299)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Nov 5 03:02:00 PST 2025


================
@@ -990,9 +990,12 @@ tileAndFuseFirstExtractUse(RewriterBase &rewriter, Diagnostic &diag,
   // from the bbArg instead. This allows to reuse the output tensor (instead of
   // creating a new one) of the container when both producer and container write
   // to the same output.
+  bool cloned = false;
   if (LoopLikeOpInterface containerLoop =
-          dyn_cast<LoopLikeOpInterface>(sliceOpToTile->getParentOp())) {
+          dyn_cast<LoopLikeOpInterface>(sliceOpToTile->getParentOp());
+      containerLoop && dyn_cast<DestinationStyleOpInterface>(producerOp)) {
----------------
ftynse wrote:

Normally, one should use `isa` rather than `dyn_cast` when the result of the cast is unused. However, having an `isa` followed by a `cast` (below) is an anti-pattern.  You can hoist `dyn_cast` to happen before the loop and just check the value for not being nullptr in the condition and use it below without the cast.  

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


More information about the Mlir-commits mailing list