Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpcmpud-2.c
blob3f09e7d3ea0f26159ca4a5ca3c290b16166f5f19
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 #if AVX512F_LEN == 512
14 #undef CMP
15 #define CMP(imm, rel) \
16 dst_ref = 0; \
17 for (i = 0; i < 16; 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_epu32_mask (source1.x, source2.x, imm);\
24 dst2 = _mm512_mask_cmp_epu32_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 < 8; 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_epu32_mask (source1.x, source2.x, imm);\
40 dst2 = _mm256_mask_cmp_epu32_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 < 4; 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_epu32_mask (source1.x, source2.x, imm);\
56 dst2 = _mm_mask_cmp_epu32_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 unsigned int s1[16] = {2134, 6678, 453, 54646,
65 231, 5674, 111, 23241,
66 12314, 145, 671, 77575,
67 23455, 166, 5321, 5673};
68 unsigned int s2[16] = {41124, 6678, 8653, 856,
69 231, 4646, 111, 124,
70 2745, 4567, 3676, 123,
71 714, 3589, 5683, 5673};
72 UNION_TYPE (AVX512F_LEN, i_d) source1, source2;
73 MASK_TYPE dst1, dst2, dst_ref;
74 MASK_TYPE mask = MASK_VALUE;
75 int i;
77 CMP(0x00, s1[i] == s2[i]);
78 CMP(0x01, s1[i] < s2[i]);
79 CMP(0x02, s1[i] <= s2[i]);
80 CMP(0x03, 0);
81 CMP(0x04, s1[i] != s2[i]);
82 CMP(0x05, s1[i] >= s2[i]);
83 CMP(0x06, s1[i] > s2[i]);
84 CMP(0x07, 1);