diff --git a/src/common/fp/op/FPConvert.cpp b/src/common/fp/op/FPConvert.cpp index 559d0242..87f965a7 100644 --- a/src/common/fp/op/FPConvert.cpp +++ b/src/common/fp/op/FPConvert.cpp @@ -59,7 +59,7 @@ FPT_TO FPConvertNaN(FPT_FROM op) { template FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr) { - const auto [type, sign, value] = FPUnpack(op, fpcr, fpsr); + const auto [type, sign, value] = FPUnpackCV(op, fpcr, fpsr); const bool is_althp = Common::BitSize() == 16 && fpcr.AHP(); if (type == FPType::SNaN || type == FPType::QNaN) { @@ -93,7 +93,7 @@ FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr) return FPInfo::Zero(sign); } - return FPRoundBase(value, fpcr, rounding_mode, fpsr); + return FPRoundCV(value, fpcr, rounding_mode, fpsr); } template u64 FPConvert(u32 op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr); diff --git a/src/common/fp/unpacked.h b/src/common/fp/unpacked.h index 132fedd0..ae206c19 100644 --- a/src/common/fp/unpacked.h +++ b/src/common/fp/unpacked.h @@ -54,6 +54,12 @@ constexpr FPUnpacked ToNormalized(bool sign, int exponent, u64 value) { template std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr); +template +std::tuple FPUnpackCV(FPT op, FPCR fpcr, FPSR& fpsr) { + fpcr.FZ16(false); + return FPUnpack(op, fpcr, fpsr); +} + template FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr); @@ -63,6 +69,12 @@ FPT FPRound(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { return FPRoundBase(op, fpcr, rounding, fpsr); } +template +FPT FPRoundCV(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { + fpcr.FZ16(false); + return FPRoundBase(op, fpcr, rounding, fpsr); +} + template FPT FPRound(FPUnpacked op, FPCR fpcr, FPSR& fpsr) { return FPRound(op, fpcr, fpcr.RMode(), fpsr);