Does _control87() also set the SSE MXCSR Control Register?

元气小坏坏 提交于 2019-12-10 21:23:13

问题


The documentation for _control87 notes:

_control87 [...] affect[s] the control words for both the x87 and the SSE2, if present.

It seems that the SSE and SSE2 MXCSR control registers are identical, however, there is no mention of the SSE unit in the documentation. Does _control87 affect an SSE unit's MXCSR control register or is this only true for SSE2?


回答1:


I dug out an old Pentium III and checked with the following code:

#include <Windows.h>
#include <float.h>
#include <xmmintrin.h>
#include <iostream>
#include <iomanip>

int _tmain( int argc, _TCHAR* argv[] ) {
    using namespace std;

    // Unmask all SSE/SSE2 exceptions
    _MM_SET_EXCEPTION_MASK( 0 );
    // Get SSE/SSE2 exception mask
    DWORD dwExceptionMask = _MM_GET_EXCEPTION_MASK();
    cout << "Exception Mask: 0x" << hex << setw( 8 )
         << setfill( '0' ) << dwExceptionMask << endl;

    // Mask all FPU exceptions
    _control87( 0xFFFF, _MCW_EM );

    // Get SSE/SSE2 exception mask
    dwExceptionMask = _MM_GET_EXCEPTION_MASK();
    cout << "Exception Mask: 0x" << hex << setw( 8 )
         << setfill( '0' ) << dwExceptionMask << endl;

    return 0;
}

Result on Pentium III (SSE):

Exception Mask: 0x00000000
Exception Mask: 0x00000000

Result on Xeon (SSE, SSE2, SSE3, SSSE3):

Exception Mask: 0x00000000
Exception Mask: 0x00001e80

The results are surprising, but in line with the documentation. _control87 only has an effect on the MXCSR control register if at least an SSE2 unit is available.




回答2:


One MXCSR controls both sse and sse2 (and sse3 and ssse3 and sse4.1 and ...)



来源:https://stackoverflow.com/questions/20045968/does-control87-also-set-the-sse-mxcsr-control-register

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!