| 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 <string.h> |
| 13 |
|
| 14 |
#define SIZE (AVX512F_LEN / 32) |
| 15 |
#include "avx512f-mask-type.h" |
| 16 |
|
| 17 |
static void |
| 18 |
CALC (float *s, int *r) |
| 19 |
{ |
| 20 |
int i; |
| 21 |
|
| 22 |
for (i = 0; i < SIZE; i++) |
| 23 |
{ |
| 24 |
if (s[i] > INT_MAX) |
| 25 |
r[i] = INT_MAX; |
| 26 |
else if (s[i] < INT_MIN) |
| 27 |
r[i] = INT_MIN; |
| 28 |
else |
| 29 |
r[i] = s[i]; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
void |
| 34 |
TEST (void) |
| 35 |
{ |
| 36 |
UNION_TYPE (AVX512F_LEN, ) s; |
| 37 |
UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3; |
| 38 |
MASK_TYPE mask = MASK_VALUE; |
| 39 |
int res_ref[SIZE] = { 0 }, res_ref2[SIZE]; |
| 40 |
int i, sign = 1; |
| 41 |
|
| 42 |
for (i = 0; i < SIZE; i++) |
| 43 |
{ |
| 44 |
s.a[i] = 1.23 * (i + 2) * sign; |
| 45 |
sign = -sign; |
| 46 |
} |
| 47 |
|
| 48 |
for (i = 0; i < SIZE; i++) |
| 49 |
res2.a[i] = DEFAULT_VALUE; |
| 50 |
|
| 51 |
res1.x = INTRINSIC (_cvtts_ps_epi32) (s.x); |
| 52 |
res2.x = INTRINSIC (_mask_cvtts_ps_epi32) (res2.x, mask, s.x); |
| 53 |
res3.x = INTRINSIC (_maskz_cvtts_ps_epi32) (mask, s.x); |
| 54 |
|
| 55 |
CALC (s.a, res_ref); |
| 56 |
memcpy(res_ref2, res_ref, sizeof(res_ref)); |
| 57 |
|
| 58 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref)) |
| 59 |
abort (); |
| 60 |
|
| 61 |
MASK_MERGE (i_d) (res_ref, mask, SIZE); |
| 62 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref)) |
| 63 |
abort (); |
| 64 |
|
| 65 |
MASK_ZERO (i_d) (res_ref, mask, SIZE); |
| 66 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref)) |
| 67 |
abort (); |
| 68 |
|
| 69 |
#if AVX512F_LEN == 512 |
| 70 |
for (i = 0; i < SIZE; i++) |
| 71 |
res2.a[i] = DEFAULT_VALUE; |
| 72 |
|
| 73 |
res1.x = INTRINSIC (_cvtts_roundps_epi32) (s.x, 8); |
| 74 |
res2.x = INTRINSIC (_mask_cvtts_roundps_epi32) (res2.x, mask, s.x, 8); |
| 75 |
res3.x = INTRINSIC (_maskz_cvtts_roundps_epi32) (mask, s.x, 8); |
| 76 |
|
| 77 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref2)) |
| 78 |
abort (); |
| 79 |
|
| 80 |
MASK_MERGE (i_d) (res_ref2, mask, SIZE); |
| 81 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref2)) |
| 82 |
abort (); |
| 83 |
|
| 84 |
MASK_ZERO (i_d) (res_ref2, mask, SIZE); |
| 85 |
if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref2)) |
| 86 |
abort (); |
| 87 |
#endif |
| 88 |
} |