[Mlir-commits] [mlir] [mlir][linalg] convert arith ops to destination-passing-style. (PR #157854)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon Sep 15 03:13:07 PDT 2025


================
@@ -603,6 +612,56 @@ Value linalg::bufferizeToAllocation(
 }
 
 namespace {
+template <typename OpTy>
+FailureOr<Operation *>
+rewriteArithInDestinationPassingStyle(RewriterBase &rewriter, OpTy op) {
+  // reject ops such as `arith.constant` and `arith.select`.
+  auto numOperands = op->getNumOperands();
+  if (numOperands == 0 || numOperands > 2)
----------------
banach-space wrote:

Why?

> only unary and binary we care about.

This is what the code tells me, yes. But it doesn't say _why_. Also, if that's the case, then this would be clearer to me:
```cpp
if (numOperands != 1 && numOperands != 2)
```

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


More information about the Mlir-commits mailing list