[Mlir-commits] [mlir] [mlir][spirv] Split codegen for float min/max reductions and others (NFC) (PR #69023)

Daniil Dudkin llvmlistbot at llvm.org
Sat Oct 14 08:26:57 PDT 2023


================
@@ -381,9 +393,26 @@ struct VectorReductionPattern final
     if (Value acc = adaptor.getAcc())
       values.push_back(acc);
 
-    // Reduce them.
-    Value result = values.front();
-    for (Value next : llvm::ArrayRef(values).drop_front()) {
+    return values;
+  }
+};
+
+#define VECTOR_REDUCTION_BASE                                                  \
+  VectorReductionPatternBase<VectorReductionPattern<SPIRVUMaxOp, SPIRVUMinOp,  \
+                                                    SPIRVSMaxOp, SPIRVSMinOp>>
----------------
unterumarmung wrote:

There is other option though but it might look weird:
```cpp
template <typename SPIRVUMaxOp, typename SPIRVUMinOp, typename SPIRVSMaxOp,
          typename SPIRVSMinOp, typename..., 
          typename Base = VectorReductionPatternBase<VectorReductionPattern<SPIRVUMaxOp, SPIRVUMinOp, SPIRVSMaxOp, SPIRVSMinOp>>>
struct VectorReductionPattern final : Base {
  using Base::Base;
  ...
};
```
`typename...` is needed to protect from possible wrongful overrides of the `Base` and `typename Base` is used here as an alias.

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


More information about the Mlir-commits mailing list