[Mlir-commits] [mlir] [mlir][arith][spirv] Convert arith.truncf rounding mode to SPIR-V (PR #101547)
Jakub Kuderski
llvmlistbot at llvm.org
Thu Aug 1 13:48:39 PDT 2024
================
@@ -807,6 +807,25 @@ struct TruncIPattern final : public OpConversionPattern<arith::TruncIOp> {
// TypeCastingOp
//===----------------------------------------------------------------------===//
+static std::optional<spirv::FPRoundingMode>
+convertArithRoundingModeToSPIRV(arith::RoundingMode roundingMode) {
+ switch (roundingMode) {
+ case arith::RoundingMode::downward:
+ return spirv::FPRoundingMode::RTN;
+ case arith::RoundingMode::to_nearest_even:
+ return spirv::FPRoundingMode::RTE;
+ case arith::RoundingMode::toward_zero:
+ return spirv::FPRoundingMode::RTZ;
+ case arith::RoundingMode::upward:
+ return spirv::FPRoundingMode::RTP;
+ case arith::RoundingMode::to_nearest_away:
+ // SPIR-V FPRoundingMode decoration has no ties-away-from-zero mode
+ // (as of SPIR-V 1.6)
+ return {};
----------------
kuhar wrote:
```suggestion
return std::nullopt;
```
https://github.com/llvm/llvm-project/pull/101547
More information about the Mlir-commits
mailing list