Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpcmpq-2.c
blob857b04e6999c18bed3e127d72a8590186f15718e
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
5 #define AVX512F
7 #include "avx512f-helper.h"
9 #include <math.h>
10 #define SIZE (AVX512F_LEN / 32)
11 #include "avx512f-mask-type.h"
13 __mmask8 dst_ref;
15 #if AVX512F_LEN == 512
16 #undef CMP
17 #define CMP(imm, rel) \
18 dst_ref = 0; \
19 for (i = 0; i < 8; i++) \
20 { \
21 dst_ref = ((rel) << i) | dst_ref; \
22 } \
23 source1.x = _mm512_loadu_si512 (s1); \
24 source2.x = _mm512_loadu_si512 (s2); \
25 dst1 = _mm512_cmp_epi64_mask (source1.x, source2.x, imm);\
26 dst2 = _mm512_mask_cmp_epi64_mask (mask, source1.x, source2.x, imm);\
27 if (dst_ref != dst1) abort(); \
28 if ((mask & dst_ref) != dst2) abort();
29 #endif
31 #if AVX512F_LEN == 256
32 #undef CMP
33 #define CMP(imm, rel) \
34 dst_ref = 0; \
35 for (i = 0; i < 4; i++) \
36 { \
37 dst_ref = ((rel) << i) | dst_ref; \
38 } \
39 source1.x = _mm256_loadu_si256 ((__m256i*)s1); \
40 source2.x = _mm256_loadu_si256 ((__m256i*)s2); \
41 dst1 = _mm256_cmp_epi64_mask (source1.x, source2.x, imm);\
42 dst2 = _mm256_mask_cmp_epi64_mask (mask, source1.x, source2.x, imm);\
43 if (dst_ref != dst1) abort(); \
44 if ((mask & dst_ref) != dst2) abort();
45 #endif
47 #if AVX512F_LEN == 128
48 #undef CMP
49 #define CMP(imm, rel) \
50 dst_ref = 0; \
51 for (i = 0; i < 2; i++) \
52 { \
53 dst_ref = ((rel) << i) | dst_ref; \
54 } \
55 source1.x = _mm_loadu_si128 ((__m128i*)s1); \
56 source2.x = _mm_loadu_si128 ((__m128i*)s2); \
57 dst1 = _mm_cmp_epi64_mask (source1.x, source2.x, imm);\
58 dst2 = _mm_mask_cmp_epi64_mask (mask, source1.x, source2.x, imm);\
59 if (dst_ref != dst1) abort(); \
60 if ((mask & dst_ref) != dst2) abort();
61 #endif
63 void
64 TEST ()
66 UNION_TYPE (AVX512F_LEN, i_d) source1, source2;
67 MASK_TYPE dst1, dst2, dst_ref;
68 MASK_TYPE mask = MASK_VALUE;
69 long long s1[8] = {2134, 6678, 453, 54646,
70 231, 5674, 111, 23241};
71 long long s2[8] = {41124, 6678, 8653, 856,
72 231, 4646, 111, 124};
73 int i;
75 CMP(0x00, s1[i] == s2[i]);
76 CMP(0x01, s1[i] < s2[i]);
77 CMP(0x02, s1[i] <= s2[i]);
78 CMP(0x03, 0);
79 CMP(0x04, s1[i] != s2[i]);
80 CMP(0x05, s1[i] >= s2[i]);
81 CMP(0x06, s1[i] > s2[i]);
82 CMP(0x07, 1);