Add SSE4.2 support.

pull/1374/head
Jussi Pakkanen 8 years ago
parent 5d731b102b
commit fc68e0c63a
  1. 3
      test cases/common/139 simd/meson.build
  2. 26
      test cases/common/139 simd/simd_sse42.c
  3. 6
      test cases/common/139 simd/simdchecker.c
  4. 5
      test cases/common/139 simd/simdfuncs.h

@ -17,8 +17,6 @@ cdata = configuration_data()
# and then have a target that uses the result in links_with.
# The following headers need to be added. Also Thumb and Altivec.
#<nmmintrin.h> SSE4.2
#<ammintrin.h> SSE4A
#<wmmintrin.h> AES
#<immintrin.h> AVX
#<zmmintrin.h> AVX512
@ -31,6 +29,7 @@ simdarr = [['-mmmx', 'HAVE_MMX', 'simd_mmx', 'simd_mmx.c'],
['-msse3', 'HAVE_SSE3', 'simd_sse3', 'simd_sse3.c'],
['-mssse3', 'HAVE_SSSE3', 'simd_ssse3', 'simd_ssse3.c'],
['-msse4.1', 'HAVE_SSE41', 'simd_sse41', 'simd_sse41.c'],
['-msse4.2', 'HAVE_SSE42', 'simd_sse42', 'simd_sse42.c'],
]
foreach ia : simdarr

@ -0,0 +1,26 @@
#include<simdconfig.h>
#include<simdfuncs.h>
#include<nmmintrin.h>
#include<cpuid.h>
#include<stdint.h>
int sse42_available() {
return __builtin_cpu_supports("sse4.2");
}
void increment_sse42(float arr[4]) {
double darr[4];
__m128d val1 = _mm_set_pd(arr[0], arr[1]);
__m128d val2 = _mm_set_pd(arr[2], arr[3]);
__m128d one = _mm_set_pd1(1.0);
__m128d result = _mm_add_pd(val1, one);
_mm_store_pd(darr, result);
result = _mm_add_pd(val2, one);
_mm_store_pd(&darr[2], result);
_mm_crc32_u32(42, 99); /* A no-op, only here to use an SSE4.2 instruction. */
arr[0] = (float)darr[1];
arr[1] = (float)darr[0];
arr[2] = (float)darr[3];
arr[3] = (float)darr[2];
}

@ -17,6 +17,12 @@ int main(int argc, char **argv) {
/* Add here. The first matched one is used so put "better" instruction
* sets at the top.
*/
#if HAVE_SSE42
if(fptr == NULL && sse42_available()) {
fptr = increment_sse42;
type = "SSE42";
}
#endif
#if HAVE_SSE41
if(fptr == NULL && sse41_available()) {
fptr = increment_sse41;

@ -39,6 +39,11 @@ int sse41_available();
void increment_sse41(float arr[4]);
#endif
#if HAVE_SSE42
int sse42_available();
void increment_sse42(float arr[4]);
#endif
#if HAVE_AVX
int avx_available();
void increment_avx(float arr[4]);

Loading…
Cancel
Save