PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpcmpub-2.c
blob8fdc9f2a1d83b465b206397085fbab538f15c808
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
5 #define AVX512BW
6 #include "avx512f-helper.h"
8 #include <math.h>
9 #define SIZE (AVX512F_LEN / 16)
10 #include "avx512f-mask-type.h"
12 #if AVX512F_LEN == 512
13 #undef CMP
14 #define CMP(imm, rel) \
15 dst_ref = 0; \
16 for (i = 0; i < 64; i++) \
17 { \
18 dst_ref = ((rel) << i) | dst_ref; \
19 } \
20 source1.x = _mm512_loadu_si512 (s1); \
21 source2.x = _mm512_loadu_si512 (s2); \
22 dst1 = _mm512_cmp_epu8_mask (source1.x, source2.x, imm);\
23 dst2 = _mm512_mask_cmp_epu8_mask (mask, source1.x, source2.x, imm);\
24 if (dst_ref != dst1) abort(); \
25 if ((mask & dst_ref) != dst2) abort();
26 #endif
28 #if AVX512F_LEN == 256
29 #undef CMP
30 #define CMP(imm, rel) \
31 dst_ref = 0; \
32 for (i = 0; i < 32; i++) \
33 { \
34 dst_ref = ((rel) << i) | dst_ref; \
35 } \
36 source1.x = _mm256_loadu_si256 ((__m256i*)s1); \
37 source2.x = _mm256_loadu_si256 ((__m256i*)s2); \
38 dst1 = _mm256_cmp_epu8_mask (source1.x, source2.x, imm);\
39 dst2 = _mm256_mask_cmp_epu8_mask (mask, source1.x, source2.x, imm);\
40 if (dst_ref != dst1) abort(); \
41 if ((mask & dst_ref) != dst2) abort();
42 #endif
44 #if AVX512F_LEN == 128
45 #undef CMP
46 #define CMP(imm, rel) \
47 dst_ref = 0; \
48 for (i = 0; i < 16; i++) \
49 { \
50 dst_ref = ((rel) << i) | dst_ref; \
51 } \
52 source1.x = _mm_loadu_si128 ((__m128i*)s1); \
53 source2.x = _mm_loadu_si128 ((__m128i*)s2); \
54 dst1 = _mm_cmp_epu8_mask (source1.x, source2.x, imm);\
55 dst2 = _mm_mask_cmp_epu8_mask (mask, source1.x, source2.x, imm);\
56 if (dst_ref != dst1) abort(); \
57 if ((mask & dst_ref) != dst2) abort();
58 #endif
60 void
61 TEST ()
63 unsigned char s1[64] = {34, 78, 53, 64,
64 1, 57, 11, 231,
65 14, 45, 71, 75,
66 55, 66, 21, 73,
67 34, 68, 3, 56,
68 1, 57, 111, 241,
69 14, 15, 61, 75,
70 55, 16, 52, 3,
71 34, 78, 53, 64,
72 1, 57, 11, 231,
73 14, 45, 71, 75,
74 55, 66, 21, 73,
75 34, 68, 3, 56,
76 1, 57, 111, 241,
77 14, 15, 61, 75,
78 55, 16, 52, 3};
79 unsigned char s2[64] = {4, 68, 86, 8,
80 1, 46, 1, 1,
81 45, 67, 36, 3,
82 4, 39, 56, 56,
83 124, 78, 53, 56,
84 1, 46, 1, 12,
85 45, 47, 36, 13,
86 4, 35, 56, 67,
87 4, 68, 86, 8,
88 1, 46, 1, 1,
89 45, 67, 36, 3,
90 4, 39, 56, 56,
91 124, 78, 53, 56,
92 1, 46, 1, 12,
93 45, 47, 36, 13,
94 4, 35, 56, 67};
95 UNION_TYPE (AVX512F_LEN, i_b) source1, source2;
96 MASK_TYPE dst1, dst2, dst_ref;
97 MASK_TYPE mask = MASK_VALUE;
98 int i;
100 CMP(0x00, s1[i] == s2[i]);
101 CMP(0x01, s1[i] < s2[i]);
102 CMP(0x02, s1[i] <= s2[i]);
103 CMP(0x03, 0);
104 CMP(0x04, s1[i] != s2[i]);
105 CMP(0x05, s1[i] >= s2[i]);
106 CMP(0x06, s1[i] > s2[i]);
107 CMP(0x07, 1);