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