[Mlir-commits] [mlir] [mlir][ArithToSPIRV] Propagate fast-math flags to SPIR-V FPFastMathMode decorations (PR #193414)
Arseniy Obolenskiy
llvmlistbot at llvm.org
Fri Apr 24 02:42:47 PDT 2026
================
@@ -225,6 +240,37 @@ struct ElementwiseArithOpPattern final : OpConversionPattern<Op> {
}
};
+/// Converts elementwise unary, binary and ternary floating-point arith
+/// operations to SPIR-V operations, propagating fast-math flags as
+/// FPFastMathMode decorations.
+template <typename Op, typename SPIRVOp>
+struct ElementwiseFPOpPattern final : OpConversionPattern<Op> {
+ using OpConversionPattern<Op>::OpConversionPattern;
+
+ LogicalResult
+ matchAndRewrite(Op op, typename Op::Adaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ assert(adaptor.getOperands().size() <= 3);
+ Type dstType = this->getTypeConverter()->convertType(op.getType());
+ if (!dstType) {
+ return rewriter.notifyMatchFailure(
+ op->getLoc(),
+ llvm::formatv("failed to convert type {0} for SPIR-V", op.getType()));
+ }
+
+ auto newOp = rewriter.template replaceOpWithNewOp<SPIRVOp>(
+ op, dstType, adaptor.getOperands());
+
+ auto spirvFMF = convertArithFastMathFlagsToSPIRV(op.getFastmath());
----------------
aobolensk wrote:
Done
https://github.com/llvm/llvm-project/pull/193414
More information about the Mlir-commits
mailing list