[Mlir-commits] [mlir] [mlir][bufferization] Introduce castBufferTypeFn hook and API (PR #205080)

Matthias Springer llvmlistbot at llvm.org
Tue Jun 30 23:50:19 PDT 2026


================
@@ -172,12 +172,9 @@ struct SelectOpInterface
         return selectOp->emitError(
             "incompatible buffer types on true/false operands");
       }
-      if (trueBuffer.getType() != *targetType)
-        trueBuffer =
-            memref::CastOp::create(rewriter, loc, *targetType, trueBuffer);
-      if (falseBuffer.getType() != *targetType)
-        falseBuffer =
-            memref::CastOp::create(rewriter, loc, *targetType, falseBuffer);
+      trueBuffer = *options.createCast(rewriter, loc, *targetType, trueBuffer);
----------------
matthias-springer wrote:

nit: Can we keep the `if (trueBuffer.getType() != *targetType)` checks here? It feels a bit cleaner from an API perspective. And drop the check from `createCast`. At the moment the implementation is more like `maybeCreateCast`.

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


More information about the Mlir-commits mailing list