2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpcmpuq-2.c
blob11eb6ffebcdeca5bcbeba80e5c9e682acfc5375f
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 / 64)
11 #include "avx512f-mask-type.h"
13 #if AVX512F_LEN == 512
14 #undef CMP
15 #define CMP(imm, rel) \
16 dst_ref = 0; \
17 for (i = 0; i < 8; i++) \
18 { \
19 dst_ref = ((rel) << i) | dst_ref; \
20 } \
21 source1.x = _mm512_loadu_si512 (s1); \
22 source2.x = _mm512_loadu_si512 (s2); \
23 dst1 = _mm512_cmp_epu64_mask (source1.x, source2.x, imm);\
24 dst2 = _mm512_mask_cmp_epu64_mask (mask, source1.x, source2.x, imm);\
25 if (dst_ref != dst1) abort(); \
26 if ((mask & dst_ref) != dst2) abort();
27 #endif
29 #if AVX512F_LEN == 256
30 #undef CMP
31 #define CMP(imm, rel) \
32 dst_ref = 0; \
33 for (i = 0; i < 4; i++) \
34 { \
35 dst_ref = ((rel) << i) | dst_ref; \
36 } \
37 source1.x = _mm256_loadu_si256 ((__m256i*)s1); \
38 source2.x = _mm256_loadu_si256 ((__m256i*)s2); \
39 dst1 = _mm256_cmp_epu64_mask (source1.x, source2.x, imm);\
40 dst2 = _mm256_mask_cmp_epu64_mask (mask, source1.x, source2.x, imm);\
41 if (dst_ref != dst1) abort(); \
42 if ((mask & dst_ref) != dst2) abort();
43 #endif
45 #if AVX512F_LEN == 128
46 #undef CMP
47 #define CMP(imm, rel) \
48 dst_ref = 0; \
49 for (i = 0; i < 2; i++) \
50 { \
51 dst_ref = ((rel) << i) | dst_ref; \
52 } \
53 source1.x = _mm_loadu_si128 ((__m128i*)s1); \
54 source2.x = _mm_loadu_si128 ((__m128i*)s2); \
55 dst1 = _mm_cmp_epu64_mask (source1.x, source2.x, imm);\
56 dst2 = _mm_mask_cmp_epu64_mask (mask, source1.x, source2.x, imm);\
57 if (dst_ref != dst1) abort(); \
58 if ((mask & dst_ref) != dst2) abort();
59 #endif
61 void
62 TEST ()
64 UNION_TYPE (AVX512F_LEN, i_q) source1, source2;
65 MASK_TYPE dst1, dst2, dst_ref;
66 MASK_TYPE mask = MASK_VALUE;
67 int i;
68 unsigned long long s1[8] = {2134, 6678, 453, 54646,
69 231, 5674, 111, 23241};
70 unsigned long long s2[8] = {41124, 6678, 8653, 856,
71 231, 4646, 111, 124};
73 CMP(0x00, s1[i] == s2[i]);
74 CMP(0x01, s1[i] < s2[i]);
75 CMP(0x02, s1[i] <= s2[i]);
76 CMP(0x03, 0);
77 CMP(0x04, s1[i] != s2[i]);
78 CMP(0x05, s1[i] >= s2[i]);
79 CMP(0x06, s1[i] > s2[i]);
80 CMP(0x07, 1);