Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx10_2-512-vcvtps2ibs-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -march=x86-64-v3 -mavx10.2" } */
3 /* { dg-require-effective-target avx10_2 } */
4
5 #ifndef AVX10_2
6 #define AVX10_2
7 #define AVX10_2_512
8 #define AVX10_512BIT
9 #endif
10 #include "avx10-helper.h"
11 #include <limits.h>
12 #include <math.h>
13 #include <string.h>
14
15 #define SIZE (AVX512F_LEN / 32)
16 #include "avx512f-mask-type.h"
17
18 static void
19 CALC (float *s, int *r)
20 {
21 int i;
22 unsigned char tmp;
23
24 for (i = 0; i < SIZE; i++)
25 {
26 if (s[i] > SCHAR_MAX)
27 tmp = SCHAR_MAX;
28 else if (s[i] < SCHAR_MIN)
29 tmp = SCHAR_MIN;
30 else
31 tmp = nearbyint(s[i]);
32 r[i] = (unsigned int) tmp;
33 }
34 }
35
36 void
37 TEST (void)
38 {
39 UNION_TYPE (AVX512F_LEN, ) s;
40 UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3;
41 MASK_TYPE mask = MASK_VALUE;
42 int res_ref[SIZE] = { 0 }, res_ref2[SIZE] = { 0 };
43 int i, sign = 1;
44
45 for (i = 0; i < SIZE; i++)
46 {
47 s.a[i] = 1.23 * (i + 2) * sign;
48 sign = -sign;
49 }
50
51 for (i = 0; i < SIZE; i++)
52 res2.a[i] = DEFAULT_VALUE;
53
54 res1.x = INTRINSIC (_ipcvts_ps_epi8) (s.x);
55 res2.x = INTRINSIC (_mask_ipcvts_ps_epi8) (res2.x, mask, s.x);
56 res3.x = INTRINSIC (_maskz_ipcvts_ps_epi8) (mask, s.x);
57
58 CALC (s.a, res_ref);
59 memcpy(res_ref2, res_ref, sizeof(res_ref));
60
61 if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
62 abort ();
63
64 MASK_MERGE (i_d) (res_ref, mask, SIZE);
65 if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
66 abort ();
67
68 MASK_ZERO (i_d) (res_ref, mask, SIZE);
69 if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
70 abort ();
71
72 #if AVX512F_LEN == 512
73 for (i = 0; i < SIZE; i++)
74 res2.a[i] = DEFAULT_VALUE;
75
76 res1.x = INTRINSIC (_ipcvts_roundps_epi8) (s.x, 8);
77 res2.x = INTRINSIC (_mask_ipcvts_roundps_epi8) (res2.x, mask, s.x, 8);
78 res3.x = INTRINSIC (_maskz_ipcvts_roundps_epi8) (mask, s.x, 8);
79
80 if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref2))
81 abort ();
82
83 MASK_MERGE (i_d) (res_ref2, mask, SIZE);
84 if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref2))
85 abort ();
86
87 MASK_ZERO (i_d) (res_ref2, mask, SIZE);
88 if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref2))
89 abort ();
90 #endif
91 }