Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpcmpuw-2.c
blob587030535aff7c1e24ca476af24d059186a5462e
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw -DAVX512BW" } */
3 /* { dg-require-effective-target avx512bw } */
5 #include "avx512f-helper.h"
7 #include <math.h>
8 #define SIZE (AVX512F_LEN / 16)
9 #include "avx512f-mask-type.h"
11 #if AVX512F_LEN == 512
12 #undef CMP
13 #define CMP(imm, rel) \
14 dst_ref = 0; \
15 for (i = 0; i < 32; i++) \
16 { \
17 dst_ref = ((rel) << i) | dst_ref; \
18 } \
19 source1.x = _mm512_loadu_si512 (s1); \
20 source2.x = _mm512_loadu_si512 (s2); \
21 dst1 = _mm512_cmp_epu16_mask (source1.x, source2.x, imm);\
22 dst2 = _mm512_mask_cmp_epu16_mask (mask, source1.x, source2.x, imm);\
23 if (dst_ref != dst1) abort(); \
24 if ((mask & dst_ref) != dst2) abort();
25 #endif
27 #if AVX512F_LEN == 256
28 #undef CMP
29 #define CMP(imm, rel) \
30 dst_ref = 0; \
31 for (i = 0; i < 16; i++) \
32 { \
33 dst_ref = ((rel) << i) | dst_ref; \
34 } \
35 source1.x = _mm256_loadu_si256 ((__m256i*)s1); \
36 source2.x = _mm256_loadu_si256 ((__m256i*)s2); \
37 dst1 = _mm256_cmp_epu16_mask (source1.x, source2.x, imm);\
38 dst2 = _mm256_mask_cmp_epu16_mask (mask, source1.x, source2.x, imm);\
39 if (dst_ref != dst1) abort(); \
40 if ((mask & dst_ref) != dst2) abort();
41 #endif
43 #if AVX512F_LEN == 128
44 #undef CMP
45 #define CMP(imm, rel) \
46 dst_ref = 0; \
47 for (i = 0; i < 8; i++) \
48 { \
49 dst_ref = ((rel) << i) | dst_ref; \
50 } \
51 source1.x = _mm_loadu_si128 ((__m128i*)s1); \
52 source2.x = _mm_loadu_si128 ((__m128i*)s2); \
53 dst1 = _mm_cmp_epu16_mask (source1.x, source2.x, imm);\
54 dst2 = _mm_mask_cmp_epu16_mask (mask, source1.x, source2.x, imm);\
55 if (dst_ref != dst1) abort(); \
56 if ((mask & dst_ref) != dst2) abort();
57 #endif
59 void
60 TEST ()
62 unsigned short s1[32] = {2134, 6678, 453, 54646,
63 231, 5674, 111, 23241,
64 12314, 145, 671, 7575,
65 23455, 166, 5321, 5673,
66 2134, 6678, 453, 54646,
67 231, 5674, 111, 23241,
68 12314, 145, 671, 7575,
69 23455, 166, 5321, 5673};
70 unsigned short s2[32] = {41124, 6678, 8653, 856,
71 231, 4646, 111, 124,
72 2745, 4567, 3676, 123,
73 714, 3589, 5683, 5673,
74 41124, 6678, 8653, 856,
75 231, 4646, 111, 124,
76 2745, 4567, 3676, 123,
77 714, 3589, 5683, 5673};
78 UNION_TYPE (AVX512F_LEN, i_w) source1, source2;
79 MASK_TYPE dst1, dst2, dst_ref;
80 MASK_TYPE mask = MASK_VALUE;
81 int i;
83 CMP(0x00, s1[i] == s2[i]);
84 CMP(0x01, s1[i] < s2[i]);
85 CMP(0x02, s1[i] <= s2[i]);
86 CMP(0x03, 0);
87 CMP(0x04, s1[i] != s2[i]);
88 CMP(0x05, s1[i] >= s2[i]);
89 CMP(0x06, s1[i] > s2[i]);
90 CMP(0x07, 1);