VirtualBox

Changeset 94681 in vbox for trunk/src


Ignore:
Timestamp:
Apr 22, 2022 8:23:10 AM (3 years ago)
Author:
vboxsync
Message:

libs/softfloat: Fixed handling of denormals in softfloat_roundPackToExtF80 when underflow exceptions aren't masked, they need to be bias adjusted and raise #U. bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/softfloat-3e/source/s_roundPackToExtF80.c

    r94677 r94681  
    325325    softfloat_exceptionFlags = 0;
    326326    extFloat80_t r80Result = softfloat_roundPackToExtF80Inner( sign, exp, sig, sigExtra, roundingPrecision, pState );
    327 
    328327    if ( !(softfloat_exceptionFlags & ~pState->exceptionMask & (softfloat_flag_underflow | softfloat_flag_overflow)) ) {
    329         /* likely */
    330     }
     328        /* Denormals are fun, because they don't cause #U when masked, and the inner
     329           code here assume it's always masked. So, detect denormals and check if it
     330           was masked or not, in the latter case do bias adjust. */
     331        if (    (r80Result.signif & RT_BIT_64( 63 ))
     332             || !r80Result.signif
     333             || (pState->exceptionMask & softfloat_flag_underflow) ) {
     334            softfloat_exceptionFlags |= exceptionFlagsSaved;
     335            return r80Result;
     336        }
     337
     338        /* Denormal and underflow not masked, need to adjust the exponent bias
     339           to match 387 behaviour. */
     340        Assert( expExtF80UI64( r80Result.signExp ) == 0 );
     341        softfloat_exceptionFlags |= softfloat_flag_underflow;
     342    }
     343
    331344    /* On Intel 10980XE the FSCALE instruction can cause really large exponents
    332345       and the rounding changes when we exceed the bias adjust. */
    333     else if (exp >= RTFLOAT80U_EXP_BIAS_ADJUST + RTFLOAT80U_EXP_MAX) {
     346    if (exp >= RTFLOAT80U_EXP_BIAS_ADJUST + RTFLOAT80U_EXP_MAX) {
    334347        Assert( softfloat_exceptionFlags & softfloat_flag_overflow );
    335348        softfloat_exceptionFlags |= softfloat_flag_inexact | softfloat_flag_c1;
     
    352365        r80Result = softfloat_roundPackToExtF80Inner( sign, exp, sig, sigExtra, roundingPrecision, pState );
    353366    }
    354 
    355367    softfloat_exceptionFlags |= exceptionFlagsSaved;
    356368    return r80Result;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette