Commit 3e30c202 authored by multrus's avatar multrus
Browse files

SVD: Avoid optimizing the division on the result of maxWithSign() with...

SVD: Avoid optimizing the division on the result of maxWithSign() with -funsafe-math-optimizations; see float issue #1560
parent 1358b843
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@
#define FIX_FLOAT_1544_SBA_META_IMPRECISION_UNSAFE_MATH /* FhG: float issue 1544: imprecision in ivas_get_dirac_sba_max_md_bits() with -funsafe-math-optimizations */
#define FIX_FLOAT_1544_ITD_IMPRECISION_UNSAFE_MATH      /* FhG: float issue 1544: Avoid assert() with -funsafe-math-optimizations in stereo_td_itd() */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* Nokia: reintroduce format switching for g192 bitstreams */
#define FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN            /* FhG: float issue 1560: Avoid optimizing the division on the result of maxWithSign() with -funsafe-math-optimizations */ 

/* #################### End BE switches ################################## */

+27 −2
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ static void ApplyQRTransform( float singularVectors_Left[][MAX_OUTPUT_CHANNELS],

static void ApplyRotation( float singularVector[][MAX_OUTPUT_CHANNELS], const float c, const float s, float x11, float x12, float *f, float *g, const int16_t currentIndex1, const int16_t currentIndex2, const int16_t nChannels );

static double maxWithSign( const float a );
static float maxWithSign( const float a );

static void flushToZeroArray( float arr[MAX_OUTPUT_CHANNELS], const int16_t length );

@@ -272,7 +272,12 @@ static int16_t BidagonalDiagonalisation(
)
{
    int16_t kCh, nCh, iCh, jCh, split;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    volatile float c, s;
    float f1, f2;
#else
    float c, s, f1, f2;
#endif
    float g = 0.0f;
    int16_t convergence, iteration, found_split;
    int16_t error = 0;
@@ -385,9 +390,14 @@ static void ApplyQRTransform(
)
{
    int16_t ch, split;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, aux = 0.0f;
    volatile float mu = 0.0f, c = 1.0f, s = 1.0f;
#else
    float d = 0.0f, g = 0.0f, r = 0.0f, x_ii = 0.0f, x_split = 0.0f, x_kk = 0.0f, mu = 0.0f, aux = 0.0f;
    float c = 1.0f;
    float s = 1.0f;
#endif

    x_kk = singularValues[currentIndex];
    x_ii = singularValues[startIndex];
@@ -525,7 +535,12 @@ static void biDiagonalReductionLeft(
    float *g )
{
    int16_t iCh, jCh;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float norm_x, r;
    volatile float f;
#else
    float norm_x, f, r;
#endif

    /* Setting values to 0 */
    ( *g ) = 0.0f;
@@ -638,7 +653,12 @@ static void singularVectorsAccumulationLeft(
{
    int16_t nCh, iCh, k;
    int16_t nChannels;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float norm_y;
    volatile float t_jj, t_ii;
#else
    float norm_y, t_jj, t_ii;
#endif

    /* Processing */
    nChannels = min( nChannelsL, nChannelsC ); /* min(nChannelsL,ChannelsC) */
@@ -706,7 +726,12 @@ static void singularVectorsAccumulationRight(
{
    int16_t nCh, iCh, k;
    int16_t nChannels;
#ifdef FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN
    float norm_y, t_ii;
    volatile float ratio;
#else
    float norm_y, t_ii, ratio;
#endif

    /* Processing */
    nChannels = nChannelsC; /* nChannelsC */
@@ -810,7 +835,7 @@ static float GivensRotation(
 *
 *-------------------------------------------------------------------------*/

static double maxWithSign(
static float maxWithSign(
    const float a )
{
    if ( fabsf( a ) > SVD_MINIMUM_VALUE )