diff --git a/src/fpu/postproc/cvtshiftcalc.sv b/src/fpu/postproc/cvtshiftcalc.sv index ff3d29b90..77b8543fd 100644 --- a/src/fpu/postproc/cvtshiftcalc.sv +++ b/src/fpu/postproc/cvtshiftcalc.sv @@ -98,6 +98,6 @@ module cvtshiftcalc import cvw::*; #(parameter cvw_t P) ( // determine if the result underflows ??? -> fp // - if the first 1 is shifted out of the result then the result underflows // - can't underflow an integer to fp conversions - assign CvtResUf = ($signed(CvtCe) < $signed({{P.NE-$clog2(P.NF){1'b1}}, ResNegNF}))&~XZero&~IntToFp; + assign CvtResUf = ($signed(CvtCe) < $signed({{P.NE-$clog2(P.NF){1'b1}}, ResNegNF}))&~XZero; // dh &~IntToFp not necessary because integer to float conversion never underflows endmodule diff --git a/src/fpu/postproc/fmashiftcalc.sv b/src/fpu/postproc/fmashiftcalc.sv index 0a8ac3035..b13b6d3da 100644 --- a/src/fpu/postproc/fmashiftcalc.sv +++ b/src/fpu/postproc/fmashiftcalc.sv @@ -101,9 +101,9 @@ module fmashiftcalc import cvw::*; #(parameter cvw_t P) ( assign Sum2GEFL = $signed(PreNormSumExp) >= $signed((P.NE+2)'(-P.NF2-2+P.BIAS-P.BIAS2)) | ~|PreNormSumExp; always_comb begin case (Fmt) - P.FMT: FmaPreResultSubnorm = Sum0LEZ & Sum0GEFL & ~FmaSZero; - P.FMT1: FmaPreResultSubnorm = Sum1LEZ & Sum1GEFL & ~FmaSZero; - P.FMT2: FmaPreResultSubnorm = Sum2LEZ & Sum2GEFL & ~FmaSZero; + P.FMT: FmaPreResultSubnorm = Sum0LEZ & Sum0GEFL; // & ~FmaSZero; // checking sum is not zero is harmless but turns out to be unnecessary + P.FMT1: FmaPreResultSubnorm = Sum1LEZ & Sum1GEFL; // & ~FmaSZero; + P.FMT2: FmaPreResultSubnorm = Sum2LEZ & Sum2GEFL; // & ~FmaSZero; default: FmaPreResultSubnorm = 1'bx; endcase end diff --git a/tests/coverage/fpu.S b/tests/coverage/fpu.S index cfb3fb4b0..3bf4c5422 100644 --- a/tests/coverage/fpu.S +++ b/tests/coverage/fpu.S @@ -164,6 +164,28 @@ main: fcvt.s.w ft2, zero fdiv.s ft3, ft1, ft2 +/* These didn't make a difference + + // Test subtraction of identical denormalized numbers with to exercise FmaPreResultSubnorm logic with FmaSZero + li t0, 0xFFFFFFFF00000001 + fmv.w.x ft1, t0 // smallest denorm + fsub.s ft1, ft1, ft1 // difference = 0 + + li t0, 0x0000000000000001 + fmv.d.x ft1, t0 // smallest denorm + fsub.d ft1, ft1, ft1 // difference = 0 + + // Test subtraction of identical denormalized numbers with to exercise FmaPreResultSubnorm logic with FmaSZero + li t0, 0xFFFFFFFF00100001 + fmv.w.x ft1, t0 // almost largest denorm + fsub.s ft1, ft1, ft1 // difference = 0 + + li t0, 0x0001000000000001 + fmv.d.x ft1, t0 // smallest denorm + fsub.d ft1, ft1, ft1 // difference = 0 + +*/ + # Test floating point convert to integer and using result fcvt.w.s t0, f0 add t1, t0, t0