| 1 |
/* { dg-require-effective-target arm_v8_2a_fp16_neon_hw } */ |
| 2 |
/* { dg-add-options arm_v8_2a_fp16_neon } */ |
| 3 |
/* { dg-skip-if "" { arm*-*-* } } */ |
| 4 |
|
| 5 |
#include <arm_neon.h> |
| 6 |
#include "arm-neon-ref.h" |
| 7 |
#include "compute-ref-data.h" |
| 8 |
|
| 9 |
#define FP16_C(a) ((__fp16) a) |
| 10 |
#define A FP16_C (123.4) |
| 11 |
#define B FP16_C (__builtin_nanf ("")) /* NaN */ |
| 12 |
#define C FP16_C (-34.8) |
| 13 |
#define D FP16_C (1024) |
| 14 |
#define E FP16_C (663.1) |
| 15 |
#define F FP16_C (169.1) |
| 16 |
#define G FP16_C (-4.8) |
| 17 |
#define H FP16_C (-__builtin_nanf ("")) /* NaN */ |
| 18 |
|
| 19 |
#define I FP16_C (0.7) |
| 20 |
#define J FP16_C (-78) |
| 21 |
#define K FP16_C (101.23) |
| 22 |
#define L FP16_C (-1098) |
| 23 |
#define M FP16_C (870.1) |
| 24 |
#define N FP16_C (-8781) |
| 25 |
#define O FP16_C (__builtin_inff ()) /* +Inf */ |
| 26 |
#define P FP16_C (-__builtin_inff ()) /* -Inf */ |
| 27 |
|
| 28 |
|
| 29 |
/* Expected results for vpminnm. */ |
| 30 |
VECT_VAR_DECL (expected_min_static, hfloat, 16, 4) [] |
| 31 |
= { 0x57B6 /* A. */, 0xD05A /* C. */, 0x5949 /* F. */, 0xC4CD /* G. */ }; |
| 32 |
|
| 33 |
VECT_VAR_DECL (expected_min_static, hfloat, 16, 8) [] |
| 34 |
= { 0x57B6 /* A. */, 0xD05A /* C. */, 0xD4E0 /* J. */, 0xE44A /* L. */, |
| 35 |
0x5949 /* F. */, 0xC4CD /* G. */, 0xF04A /* N. */, 0xFC00 /* P. */ }; |
| 36 |
|
| 37 |
/* expected_max results for vpmaxnm. */ |
| 38 |
VECT_VAR_DECL (expected_max_static, hfloat, 16, 4) [] |
| 39 |
= { 0x57B6 /* A. */, 0x6400 /* D. */, 0x612E /* E. */, 0xC4CD /* G. */ }; |
| 40 |
|
| 41 |
VECT_VAR_DECL (expected_max_static, hfloat, 16, 8) [] |
| 42 |
= { 0x57B6 /* A. */, 0x6400 /* D. */, 0x399A /* I. */, 0x5654 /* K. */, |
| 43 |
0x612E /* E. */, 0xC4CD /* G. */, 0x62CC /* M. */, 0x7C00 /* O. */ }; |
| 44 |
|
| 45 |
void exec_vpminmaxnm_f16 (void) |
| 46 |
{ |
| 47 |
#undef TEST_MSG |
| 48 |
#define TEST_MSG "VPMINNM (FP16)" |
| 49 |
clean_results (); |
| 50 |
|
| 51 |
DECL_VARIABLE(vsrc_1, float, 16, 4); |
| 52 |
DECL_VARIABLE(vsrc_2, float, 16, 4); |
| 53 |
VECT_VAR_DECL (buf_src_1, float, 16, 4) [] = {A, B, C, D}; |
| 54 |
VECT_VAR_DECL (buf_src_2, float, 16, 4) [] = {E, F, G, H}; |
| 55 |
VLOAD (vsrc_1, buf_src_1, , float, f, 16, 4); |
| 56 |
VLOAD (vsrc_2, buf_src_2, , float, f, 16, 4); |
| 57 |
DECL_VARIABLE (vector_res, float, 16, 4) |
| 58 |
= vpminnm_f16 (VECT_VAR (vsrc_1, float, 16, 4), |
| 59 |
VECT_VAR (vsrc_2, float, 16, 4)); |
| 60 |
vst1_f16 (VECT_VAR (result, float, 16, 4), |
| 61 |
VECT_VAR (vector_res, float, 16, 4)); |
| 62 |
|
| 63 |
CHECK_FP (TEST_MSG, float, 16, 4, PRIx16, expected_min_static, ""); |
| 64 |
|
| 65 |
#undef TEST_MSG |
| 66 |
#define TEST_MSG "VPMINNMQ (FP16)" |
| 67 |
clean_results (); |
| 68 |
|
| 69 |
DECL_VARIABLE(vsrc_1, float, 16, 8); |
| 70 |
DECL_VARIABLE(vsrc_2, float, 16, 8); |
| 71 |
VECT_VAR_DECL (buf_src_1, float, 16, 8) [] = {A, B, C, D, I, J, K, L}; |
| 72 |
VECT_VAR_DECL (buf_src_2, float, 16, 8) [] = {E, F, G, H, M, N, O, P}; |
| 73 |
VLOAD (vsrc_1, buf_src_1, q, float, f, 16, 8); |
| 74 |
VLOAD (vsrc_2, buf_src_2, q, float, f, 16, 8); |
| 75 |
DECL_VARIABLE (vector_res, float, 16, 8) |
| 76 |
= vpminnmq_f16 (VECT_VAR (vsrc_1, float, 16, 8), |
| 77 |
VECT_VAR (vsrc_2, float, 16, 8)); |
| 78 |
vst1q_f16 (VECT_VAR (result, float, 16, 8), |
| 79 |
VECT_VAR (vector_res, float, 16, 8)); |
| 80 |
|
| 81 |
CHECK_FP (TEST_MSG, float, 16, 8, PRIx16, expected_min_static, ""); |
| 82 |
|
| 83 |
#undef TEST_MSG |
| 84 |
#define TEST_MSG "VPMAXNM (FP16)" |
| 85 |
clean_results (); |
| 86 |
|
| 87 |
VECT_VAR (vector_res, float, 16, 4) |
| 88 |
= vpmaxnm_f16 (VECT_VAR (vsrc_1, float, 16, 4), |
| 89 |
VECT_VAR (vsrc_2, float, 16, 4)); |
| 90 |
vst1_f16 (VECT_VAR (result, float, 16, 4), |
| 91 |
VECT_VAR (vector_res, float, 16, 4)); |
| 92 |
|
| 93 |
CHECK_FP (TEST_MSG, float, 16, 4, PRIx16, expected_max_static, ""); |
| 94 |
|
| 95 |
#undef TEST_MSG |
| 96 |
#define TEST_MSG "VPMAXNMQ (FP16)" |
| 97 |
clean_results (); |
| 98 |
|
| 99 |
VECT_VAR (vector_res, float, 16, 8) |
| 100 |
= vpmaxnmq_f16 (VECT_VAR (vsrc_1, float, 16, 8), |
| 101 |
VECT_VAR (vsrc_2, float, 16, 8)); |
| 102 |
vst1q_f16 (VECT_VAR (result, float, 16, 8), |
| 103 |
VECT_VAR (vector_res, float, 16, 8)); |
| 104 |
|
| 105 |
CHECK_FP (TEST_MSG, float, 16, 8, PRIx16, expected_max_static, ""); |
| 106 |
} |
| 107 |
|
| 108 |
int |
| 109 |
main (void) |
| 110 |
{ |
| 111 |
exec_vpminmaxnm_f16 (); |
| 112 |
return 0; |
| 113 |
} |