[Mlir-commits] [mlir] [mlir][Transforms] Improve `replaceOpWithMultiple` API (PR #132608)

Matthias Springer llvmlistbot at llvm.org
Tue Mar 25 06:35:37 PDT 2025


================
@@ -898,6 +898,11 @@ class ConversionPatternRewriter final : public PatternRewriter {
   /// Replace the given operation with the new value ranges. The number of op
   /// results and value ranges must match. The given  operation is erased.
   void replaceOpWithMultiple(Operation *op, ArrayRef<ValueRange> newValues);
+  template <typename RangeT>
+  void replaceOpWithMultiple(Operation *op, RangeT &&newValues) {
----------------
matthias-springer wrote:

To avoid the copy, an `ArrayRef<SmallVector<Value, 1>>` must be used because the internal dialect conversion representation in the mapping data structure is `SmallVector<Value, 1>`.

It's bit tricky to make all the overloads work. But I think I found a solution. @zero9178 Can you give this another sanity check? You know this stuff better...

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


More information about the Mlir-commits mailing list