From af2e5afed6354ecd67b804d27f143733795d024a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 13 Apr 2019 18:58:15 -0400 Subject: [PATCH] common/fp/op: Add half-precision specialization for FPRecipEstimate --- src/common/fp/op/FPRecipEstimate.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/common/fp/op/FPRecipEstimate.cpp b/src/common/fp/op/FPRecipEstimate.cpp index 95e02a07..c35a6569 100644 --- a/src/common/fp/op/FPRecipEstimate.cpp +++ b/src/common/fp/op/FPRecipEstimate.cpp @@ -31,12 +31,12 @@ FPT FPRecipEstimate(FPT op, FPCR fpcr, FPSR& fpsr) { } if (type == FPType::Infinity) { - return FPInfo::Zero(sign); + return FPT(FPInfo::Zero(sign)); } if (type == FPType::Zero) { FPProcessException(FPExc::DivideByZero, fpcr, fpsr); - return FPInfo::Infinity(sign); + return FPT(FPInfo::Infinity(sign)); } if (value.exponent < FPInfo::exponent_min - 2) { @@ -58,13 +58,13 @@ FPT FPRecipEstimate(FPT op, FPCR fpcr, FPSR& fpsr) { FPProcessException(FPExc::Overflow, fpcr, fpsr); FPProcessException(FPExc::Inexact, fpcr, fpsr); - return overflow_to_inf ? FPInfo::Infinity(sign) : FPInfo::MaxNormal(sign); + return overflow_to_inf ? FPT(FPInfo::Infinity(sign)) : FPT(FPInfo::MaxNormal(sign)); } if ((fpcr.FZ() && !std::is_same_v) || (fpcr.FZ16() && std::is_same_v)) { if (value.exponent >= -FPInfo::exponent_min) { fpsr.UFC(true); - return FPInfo::Zero(sign); + return FPT(FPInfo::Zero(sign)); } } @@ -87,12 +87,13 @@ FPT FPRecipEstimate(FPT op, FPCR fpcr, FPSR& fpsr) { } } - const FPT bits_sign = FPInfo::Zero(sign); + const FPT bits_sign = FPT(FPInfo::Zero(sign)); const FPT bits_exponent = static_cast(result_exponent + FPInfo::exponent_bias); const FPT bits_mantissa = static_cast(estimate); - return (bits_exponent << FPInfo::explicit_mantissa_width) | (bits_mantissa & FPInfo::mantissa_mask) | bits_sign; + return FPT((bits_exponent << FPInfo::explicit_mantissa_width) | (bits_mantissa & FPInfo::mantissa_mask) | bits_sign); } +template u16 FPRecipEstimate(u16 op, FPCR fpcr, FPSR& fpsr); template u32 FPRecipEstimate(u32 op, FPCR fpcr, FPSR& fpsr); template u64 FPRecipEstimate(u64 op, FPCR fpcr, FPSR& fpsr);