[Mlir-commits] [mlir] [mlir][math] Add vector support for math-to-apfloat (PR #172715)

Maksim Levental llvmlistbot at llvm.org
Thu Jan 15 15:53:50 PST 2026


================
@@ -9,13 +9,74 @@
 #ifndef MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
 #define MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
 
+#include "mlir/Dialect/Vector/IR/VectorOps.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "llvm/ADT/SmallVector.h"
+
 namespace mlir {
 class Value;
 class OpBuilder;
 class Location;
 class FloatType;
 
 Value getAPFloatSemanticsValue(OpBuilder &b, Location loc, FloatType floatTy);
+
+/// Given two operands of vector type and vector result type (with the same
+/// shape), call the given function for each pair of scalar operands and
+/// package the result into a vector. If the given operands and result type are
+/// not vectors, call the function directly. The second operand is optional.
+template <typename Fn, typename... Values>
+Value forEachScalarValue(mlir::RewriterBase &rewriter, Location loc,
+                         Value operand1, Value operand2, Type resultType,
+                         Fn fn) {
----------------
makslevental wrote:

i opted for not extending `forEachScalarValue` and therefore being able to use `llvm::function_ref` and being able to move the impl into `Util.cpp`

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


More information about the Mlir-commits mailing list