VirtualBox

Changeset 105450 in vbox


Ignore:
Timestamp:
Jul 23, 2024 2:52:34 PM (7 months ago)
Author:
vboxsync
Message:

VMM/IEM: Exception flags generation fixes for the SIMD floating point C helpers, bugref:10652

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp

    r105371 r105450  
    1558715587{
    1558815588    iemFpSoftF32ToIprt(pr32Result, r32Result);
    15589 
    1559015589    uint8_t fXcpt = pSoftState->exceptionFlags;
    15591     if (   (fMxcsr & X86_MXCSR_FZ)
    15592         && RTFLOAT32U_IS_SUBNORMAL(pr32Result))
    15593     {
    15594         /* Underflow masked and flush to zero is set. */
    15595         pr32Result->s.uFraction = 0;
    15596         pr32Result->s.uExponent = 0;
    15597         fXcpt |= X86_MXCSR_UE | X86_MXCSR_PE;
    15598     }
    15599 
    1560015590    /* If DAZ is set \#DE is never set. */
    1560115591    if (   fMxcsr & X86_MXCSR_DAZ
     
    1560315593            && (RTFLOAT32U_IS_SUBNORMAL(pr32Result))))
    1560415594        fXcpt &= ~X86_MXCSR_DE;
     15595
     15596    /*
     15597     * Skip computing the post-computational exception flags if any of the pre-computational exception flags
     15598     * are set and are unmasked in MXCSR.
     15599     */
     15600    if (  ((fMxcsr | fXcpt) & (X86_MXCSR_IE | X86_MXCSR_DE | X86_MXCSR_ZE))
     15601        & ~((fMxcsr & X86_MXCSR_XCPT_MASK) >> X86_MXCSR_XCPT_MASK_SHIFT))
     15602        return fMxcsr | (fXcpt & (X86_MXCSR_IE | X86_MXCSR_DE | X86_MXCSR_ZE));
     15603
     15604    if (   (fMxcsr & X86_MXCSR_FZ)
     15605        && RTFLOAT32U_IS_SUBNORMAL(pr32Result))
     15606    {
     15607        /* Underflow masked and flush to zero is set. */
     15608        pr32Result->s.uFraction = 0;
     15609        pr32Result->s.uExponent = 0;
     15610        fXcpt |= X86_MXCSR_UE | X86_MXCSR_PE;
     15611    }
     15612
     15613    /* If OE/UE get raised PE won't be set because of the lower priority. */
     15614    if (   (   ((fXcpt & (X86_MXCSR_PE | X86_MXCSR_OE)) == (X86_MXCSR_PE | X86_MXCSR_OE))
     15615            && !(fMxcsr & X86_MXCSR_OM))
     15616        || (   ((fXcpt & (X86_MXCSR_PE | X86_MXCSR_UE)) == (X86_MXCSR_PE | X86_MXCSR_UE))
     15617            && !(fMxcsr & X86_MXCSR_UM)))
     15618        fXcpt &= ~X86_MXCSR_PE;
    1560515619
    1560615620    return fMxcsr | (fXcpt & X86_MXCSR_XCPT_FLAGS);
     
    1563915653 *
    1564015654 * @returns Updated MXCSR.
    15641  * @param   pSoftState      The SoftFloat state following the operation.
    15642  * @param   r64Result       The result of the SoftFloat operation.
    15643  * @param   pr64Result      Where to store the result for IEM.
    15644  * @param   fMxcsr          The original MXCSR value.
     15655 * @param   pSoftState           The SoftFloat state following the operation.
     15656 * @param   r64Result            The result of the SoftFloat operation.
     15657 * @param   pr64Result           Where to store the result for IEM.
     15658 * @param   fMxcsr               The original MXCSR value.
    1564515659 */
    1564615660DECLINLINE(uint32_t) iemSseSoftStateAndR64ToMxcsrAndIprtResult(softfloat_state_t const *pSoftState, float64_t r64Result,
     
    1564915663    iemFpSoftF64ToIprt(pr64Result, r64Result);
    1565015664    uint8_t fXcpt = pSoftState->exceptionFlags;
    15651     if (   (fMxcsr & X86_MXCSR_FZ)
    15652         && RTFLOAT64U_IS_SUBNORMAL(pr64Result))
    15653     {
    15654         /* Underflow masked and flush to zero is set. */
    15655         iemFpSoftF64ToIprt(pr64Result, r64Result);
    15656         pr64Result->s.uFractionHigh = 0;
    15657         pr64Result->s.uFractionLow  = 0;
    15658         pr64Result->s.uExponent     = 0;
    15659         fXcpt |= X86_MXCSR_UE | X86_MXCSR_PE;
    15660     }
    15661 
    1566215665    /* If DAZ is set \#DE is never set. */
    1566315666    if (   fMxcsr & X86_MXCSR_DAZ
     
    1566515668            && (RTFLOAT64U_IS_SUBNORMAL(pr64Result))))
    1566615669        fXcpt &= ~X86_MXCSR_DE;
     15670
     15671    /*
     15672     * Skip computing the post-computational exception flags if any of the pre-computational exception flags
     15673     * are set and are unmasked in MXCSR.
     15674     */
     15675    if (  ((fMxcsr | fXcpt) & (X86_MXCSR_IE | X86_MXCSR_DE | X86_MXCSR_ZE))
     15676        & ~((fMxcsr & X86_MXCSR_XCPT_MASK) >> X86_MXCSR_XCPT_MASK_SHIFT))
     15677        return fMxcsr | (fXcpt & (X86_MXCSR_IE | X86_MXCSR_DE | X86_MXCSR_ZE));
     15678
     15679    if (   (fMxcsr & X86_MXCSR_FZ)
     15680        && RTFLOAT64U_IS_SUBNORMAL(pr64Result))
     15681    {
     15682        /* Underflow masked and flush to zero is set. */
     15683        pr64Result->s.uFractionHigh = 0;
     15684        pr64Result->s.uFractionLow  = 0;
     15685        pr64Result->s.uExponent     = 0;
     15686        fXcpt |= X86_MXCSR_UE | X86_MXCSR_PE;
     15687    }
     15688
     15689    /* If OE/UE get raised PE won't be set because of the lower priority. */
     15690    if (   (   ((fXcpt & (X86_MXCSR_PE | X86_MXCSR_OE)) == (X86_MXCSR_PE | X86_MXCSR_OE))
     15691            && !(fMxcsr & X86_MXCSR_OM))
     15692        || (   ((fXcpt & (X86_MXCSR_PE | X86_MXCSR_UE)) == (X86_MXCSR_PE | X86_MXCSR_UE))
     15693            && !(fMxcsr & X86_MXCSR_UM)))
     15694        fXcpt &= ~X86_MXCSR_PE;
    1566715695
    1566815696    return fMxcsr | (fXcpt & X86_MXCSR_XCPT_FLAGS);
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