[Mlir-commits] [mlir] [mlir][math] Add vector support for math-to-apfloat (PR #172715)
Matthias Springer
llvmlistbot at llvm.org
Sat Jan 10 02:26:50 PST 2026
================
@@ -151,8 +151,52 @@ struct FmaOpToAPFloatConversion final : OpRewritePattern<math::FmaOp> {
Location loc = op.getLoc();
rewriter.setInsertionPoint(op);
- auto intWType = rewriter.getIntegerType(floatTy.getWidth());
- auto int64Type = rewriter.getI64Type();
+ IntegerType intWType = rewriter.getIntegerType(floatTy.getWidth());
+ IntegerType int64Type = rewriter.getI64Type();
+
+ auto scalarFMA = [&rewriter, &loc, &floatTy, &fn, &intWType](
+ Value operand, Value multiplicand, Value addend) {
+ // Call APFloat function.
+ Value semValue = getAPFloatSemanticsValue(rewriter, loc, floatTy);
+ SmallVector<Value> params = {semValue, operand, multiplicand, addend};
+ auto resultOp =
+ func::CallOp::create(rewriter, loc, TypeRange(rewriter.getI64Type()),
+ SymbolRefAttr::get(*fn), params);
+
+ // Truncate result to the original width.
+ auto trunc = arith::TruncIOp::create(rewriter, loc, intWType,
+ resultOp->getResult(0));
+ return arith::BitcastOp::create(rewriter, loc, floatTy, trunc);
+ };
+
+ if (VectorType vecTy1 = dyn_cast<VectorType>(op.getA().getType())) {
----------------
matthias-springer wrote:
Can `forEachScalarValue` be used here? It is unused at the moment, but I wrote `typename... Values` to support an arbitrary number of operands. Seems like I abandoned that implementation for some reason...
https://github.com/llvm/llvm-project/pull/172715
More information about the Mlir-commits
mailing list