[Mlir-commits] [mlir] [mlir][bufferization] Return BufferLikeType in BufferizableOpInterface (PR #144867)

Matthias Springer llvmlistbot at llvm.org
Mon Jun 30 02:26:49 PDT 2025


================
@@ -196,17 +196,17 @@ struct SelectOpInterface
     if (failed(trueType) || failed(falseType))
       return failure();
     if (*trueType == *falseType)
-      return *trueType;
+      return cast<BufferLikeType>(*trueType);
     if (trueType->getMemorySpace() != falseType->getMemorySpace())
----------------
matthias-springer wrote:

> is it reasonable to assume all buffers have an associated memory space?

How would that help?

The memory space is optional, it could be `Attribute()`.

That being said, the `bufferize` implementation of `arith.select` is hard-coded to memref types: it inserts `memref.cast` operations. Therefore, I'd say it's reasonable to also hard-code the `getBufferType` implementation to memref types.

If you'd like to extend this (so that `arith.select` can work with custom buffer types), you'd have to add interface methods to `BufferLikeType` to query if two buffer-like types are cast compatible.


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


More information about the Mlir-commits mailing list