Commit ca43c4f5 authored by Manuel Jander's avatar Manuel Jander
Browse files

Issue #1010 : Add output normalization and x==0 handling to BASOP_Util_Inv32...

Issue #1010 : Add output normalization and x==0 handling to BASOP_Util_Inv32 to prevent instabilities for some operating points.
parent 5aae8ccc
Loading
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1044,7 +1044,14 @@ Word32 div_w( Word32 L_num, Word32 L_den )
static
Word32 BASOP_Util_Inv32(Word32 x, Word16 *px_e)
{
    Word16 sign, shift;
    Word16 sign, shift, shift2;

    /* Avoid result 0 with inconvenient exponent returned. */
    IF( x == (Word32) 0 )
    {
        *px_e = 0;
        return ( (Word32) 0 );
    }

    sign = 0;
    move16();
@@ -1061,7 +1068,9 @@ Word32 BASOP_Util_Inv32(Word32 x, Word16 *px_e)
    move16();
    x = ISqrt32norm(x, px_e);
    x = Mpy_32_32(x, x);
    *px_e = add(shl(*px_e, 1), shift);
    shift2 = norm_l(x);
    x = L_shl(x, shift2);
    *px_e = add(shl(*px_e, 1), sub(shift, shift2));
    move16();

    if (sign) {