| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mavx512f -O2" } */ |
| 3 |
/* { dg-require-effective-target avx512f } */ |
| 4 |
|
| 5 |
#define SIZE (128 / 32) |
| 6 |
|
| 7 |
#include <math.h> |
| 8 |
#include "avx512f-check.h" |
| 9 |
#include "avx512f-mask-type.h" |
| 10 |
|
| 11 |
static void |
| 12 |
compute_rndscaless (float *s1, float *s2, float *r, int imm) |
| 13 |
{ |
| 14 |
int rc, m; |
| 15 |
rc = imm & 0xf; |
| 16 |
m = imm >> 4; |
| 17 |
|
| 18 |
switch (rc) |
| 19 |
{ |
| 20 |
case _MM_FROUND_FLOOR: |
| 21 |
r[0] = __builtin_floorf (s2[0] * pow (2, m)) / pow (2, m); |
| 22 |
break; |
| 23 |
case _MM_FROUND_CEIL: |
| 24 |
r[0] = __builtin_ceilf (s2[0] * pow (2, m)) / pow (2, m); |
| 25 |
break; |
| 26 |
default: |
| 27 |
abort (); |
| 28 |
break; |
| 29 |
} |
| 30 |
|
| 31 |
r[1] = s1[1]; |
| 32 |
r[2] = s1[2]; |
| 33 |
r[3] = s1[3]; |
| 34 |
} |
| 35 |
|
| 36 |
static void |
| 37 |
avx512f_test (void) |
| 38 |
{ |
| 39 |
int i, imm; |
| 40 |
union128 s1, s2, res1, res2, res3, res4, res5, res6; |
| 41 |
float res_ref[SIZE]; |
| 42 |
|
| 43 |
MASK_TYPE mask = MASK_VALUE; |
| 44 |
|
| 45 |
imm = _MM_FROUND_FLOOR | (7 << 4); |
| 46 |
|
| 47 |
s1.x = _mm_set_ps (4.05084, -1.23162, 2.00231, -6.22103); |
| 48 |
s2.x = _mm_set_ps (-4.19319, -3.53222, 7.33527, 5.57655); |
| 49 |
|
| 50 |
for(i = 0; i < SIZE; i++) |
| 51 |
{ |
| 52 |
res2.a[i] = DEFAULT_VALUE; |
| 53 |
res5.a[i] = DEFAULT_VALUE; |
| 54 |
} |
| 55 |
|
| 56 |
res1.x = _mm_roundscale_ss (s1.x, s2.x, imm); |
| 57 |
res2.x = _mm_mask_roundscale_ss (res2.x, mask, s1.x, s2.x, imm); |
| 58 |
res3.x = _mm_maskz_roundscale_ss (mask, s1.x, s2.x, imm); |
| 59 |
res4.x = _mm_roundscale_round_ss (s1.x, s2.x, imm, _MM_FROUND_NO_EXC); |
| 60 |
res5.x = _mm_mask_roundscale_round_ss (res5.x, mask, s1.x, s2.x, imm, _MM_FROUND_NO_EXC); |
| 61 |
res6.x = _mm_maskz_roundscale_round_ss (mask, s1.x, s2.x, imm, _MM_FROUND_NO_EXC); |
| 62 |
|
| 63 |
compute_rndscaless (s1.a, s2.a, res_ref, imm); |
| 64 |
|
| 65 |
if (check_union128 (res1, res_ref)) |
| 66 |
abort (); |
| 67 |
|
| 68 |
MASK_MERGE () (res_ref, mask, 1); |
| 69 |
if (check_union128 (res2, res_ref)) |
| 70 |
abort (); |
| 71 |
|
| 72 |
MASK_ZERO () (res_ref, mask, 1); |
| 73 |
if (check_union128 (res3, res_ref)) |
| 74 |
abort (); |
| 75 |
|
| 76 |
compute_rndscaless (s1.a, s2.a, res_ref, imm); |
| 77 |
|
| 78 |
if (check_union128 (res4, res_ref)) |
| 79 |
abort (); |
| 80 |
|
| 81 |
MASK_MERGE () (res_ref, mask, 1); |
| 82 |
if (check_union128 (res5, res_ref)) |
| 83 |
abort (); |
| 84 |
|
| 85 |
MASK_ZERO () (res_ref, mask, 1); |
| 86 |
if (check_union128 (res6, res_ref)) |
| 87 |
abort (); |
| 88 |
} |