Commit fe5f2352 authored by Emmanuel Thomé's avatar Emmanuel Thomé

better sse-4.1 test

parent 95132a6e
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <smmintrin.h>
int main() {
__m128i x = _mm_setr_epi32(42, 0, 17, 0);
__m128i y = _mm_setr_epi32(41, 0, 17, 0);
x = _mm_cmpeq_epi64(x, y);
// x = 0....0 1....1
y = _mm_insert_epi64(y, _mm_extract_epi64(x, 1), 0);
// y = 1....1 0x11
y = _mm_andnot_si128(y, y);
// y = 0....0 0x11
x = _mm_cmpeq_epi64(x, y);
// x = 1....1 1....1
int main(int argc, char * argv[])
{
/* the following test is for emulated 32-bit on physical 64-bit */
if (sizeof(unsigned long) != 8)
abort ();
unsigned int z = _mm_extract_epi32(x, 2);
return
(
(_mm_extract_epi32(x, 0) != 0)
&& (_mm_extract_epi32(x, 1) != 0)
&& (_mm_extract_epi32(x, 2) == 0)
&& (_mm_extract_epi32(x, 3) == 0)) ? EXIT_SUCCESS : EXIT_FAILURE;
if (argc < 3) {
fprintf(stderr, "This code must be called with arguments 17 and 42\n");
exit(EXIT_FAILURE);
}
__m128i x = _mm_setr_epi32(atoi(argv[2]), 0, atoi(argv[1]), 0);
// x = 0 0x2a 0 0x11
__m128i y = _mm_setr_epi32(42, 0, 17, 0);
// y = 0 0x2a 0 0x11
__m128i ma = _mm_max_epi32(x, y);
__m128i mi = _mm_min_epi32(x, y);
__m128i z = _mm_xor_si128(mi, ma);
int ok0 = _mm_testz_si128(z, z);
__m128i c = _mm_cmpeq_epi64(x, y);
int ok1 = _mm_extract_epi32(c, 0) && _mm_extract_epi32(c, 1);
return (ok0 && ok1) ? EXIT_SUCCESS : EXIT_FAILURE;
}
......@@ -4,7 +4,9 @@ message(STATUS "Testing whether sse-4.1 code can be used")
if (HAVE_SSSE3)
try_run(sse41_runs sse41_compiles
${PROJECT_BINARY_DIR}/config
${PROJECT_SOURCE_DIR}/config/sse41.c)
${PROJECT_SOURCE_DIR}/config/sse41.c
ARGS 17 42
)
if(sse41_compiles)
if (sse41_runs MATCHES FAILED_TO_RUN)
message(STATUS "Testing whether sse-4.1 code can be used -- No")
......@@ -17,7 +19,9 @@ if (HAVE_SSSE3)
try_run(sse41_runs sse41_compiles
${PROJECT_BINARY_DIR}/config
${PROJECT_SOURCE_DIR}/config/sse41.c
COMPILE_DEFINITIONS -msse4.1)
COMPILE_DEFINITIONS -msse4.1
ARGS 17 42
)
if(sse41_compiles)
if (sse41_runs MATCHES FAILED_TO_RUN)
message(STATUS "Testing whether sse-4.1 code can be used -- No")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment