-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x86: improve SIMD detection #257
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,12 +572,13 @@ static void get_cpu_features(void) | |
feature_list |= CPU_FEATURE_OSXSAVE; | ||
if (info[2] & 0x10000000) | ||
feature_list |= CPU_FEATURE_AVX; | ||
#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2) | ||
if (info[3] & 0x4000000) | ||
feature_list |= CPU_FEATURE_SSE2; | ||
#endif | ||
if (info[3] & 0x8000) | ||
feature_list |= CPU_FEATURE_CMOV; | ||
#if (defined(SLJIT_DETECT_SSE2) && SLJIT_DETECT_SSE2) \ | ||
&& (defined(__SSE2__) || (defined(_WIN64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2))) | ||
if ((info[3] & 0x5000000) == 0x5000000) | ||
feature_list |= CPU_FEATURE_SSE2; | ||
#endif | ||
} | ||
|
||
info[0] = 0x80000000; | ||
|
@@ -592,7 +593,11 @@ static void get_cpu_features(void) | |
feature_list |= CPU_FEATURE_LZCNT; | ||
} | ||
|
||
if ((feature_list & CPU_FEATURE_OSXSAVE) && (execute_get_xcr0_low() & 0x4) == 0) | ||
#if defined(SLJIT_CONFIG_X86_32) && SLJIT_CONFIG_X86_32 | ||
if (!(feature_list & CPU_FEATURE_SSE2)) | ||
feature_list &= ~(sljit_u32)CPU_FEATURE_SSE41; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who sets this? Does the compiler runs on that old hardware? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just like AVX2; SSE2 also needs OS support, which could be missing (ex: Debian 3). When Note that in this case, if saving of the XMM registers is not supported, any operation that uses them will SIGILL, hence why this code disables SSE41 (hence SIMD) in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question was how is it possible to set SSE4.1 without setting SSE2. I always worry that we accidentally disables features for newer systems. |
||
#endif | ||
if (!(feature_list & CPU_FEATURE_OSXSAVE) || (execute_get_xcr0_low() & 0x4) == 0) | ||
feature_list &= ~(sljit_u32)(CPU_FEATURE_AVX | CPU_FEATURE_AVX2); | ||
|
||
cpu_feature_list = feature_list; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will disable SSE2 with SUNPRO, TINYC or other compilers than won't provide the defines.