[Mlir-commits] [mlir] [mlir][arith][spirv] Convert arith.truncf rounding mode to SPIR-V (PR #101547)

Andrea Faulds llvmlistbot at llvm.org
Thu Aug 1 15:26:12 PDT 2024


================
@@ -829,15 +848,20 @@ struct TypeCastingOpPattern final : public OpConversionPattern<Op> {
       // Then we can just erase this operation by forwarding its operand.
       rewriter.replaceOp(op, adaptor.getOperands().front());
     } else {
-      rewriter.template replaceOpWithNewOp<SPIRVOp>(op, dstType,
-                                                    adaptor.getOperands());
+      auto newOp = rewriter.template replaceOpWithNewOp<SPIRVOp>(
+          op, dstType, adaptor.getOperands());
       if (auto roundingModeOp =
               dyn_cast<arith::ArithRoundingModeInterface>(*op)) {
         if (arith::RoundingModeAttr roundingMode =
                 roundingModeOp.getRoundingModeAttr()) {
-          // TODO: Perform rounding mode attribute conversion and attach to new
-          // operation when defined in the dialect.
-          return failure();
+          if (auto rm =
+                  convertArithRoundingModeToSPIRV(roundingMode.getValue())) {
+            newOp->setAttr(
+                getDecorationString(spirv::Decoration::FPRoundingMode),
+                spirv::FPRoundingModeAttr::get(rewriter.getContext(), *rm));
+          } else {
+            return failure(); // unsupported rounding mode
----------------
andfau-amd wrote:

Done in a4effd454f09906021e467c24f5bc8a85bbece73.

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


More information about the Mlir-commits mailing list