(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
advsimd-intrinsics/
vduph_lane.c
       1  /* { dg-do run } */
       2  /* { dg-skip-if "" { arm*-*-* } } */
       3  
       4  #include <arm_neon.h>
       5  #include "arm-neon-ref.h"
       6  #include "compute-ref-data.h"
       7  
       8  #define A -16
       9  #define B -15
      10  #define C -14
      11  #define D -13
      12  #define E -12
      13  #define F -11
      14  #define G -10
      15  #define H -9
      16  
      17  #define F16_C(a) ((__fp16) a)
      18  #define AF F16_C (A)
      19  #define BF F16_C (B)
      20  #define CF F16_C (C)
      21  #define DF F16_C (D)
      22  #define EF F16_C (E)
      23  #define FF F16_C (F)
      24  #define GF F16_C (G)
      25  #define HF F16_C (H)
      26  
      27  #define S16_C(a) ((int16_t) a)
      28  #define AS S16_C (A)
      29  #define BS S16_C (B)
      30  #define CS S16_C (C)
      31  #define DS S16_C (D)
      32  #define ES S16_C (E)
      33  #define FS S16_C (F)
      34  #define GS S16_C (G)
      35  #define HS S16_C (H)
      36  
      37  #define U16_C(a) ((int16_t) a)
      38  #define AU U16_C (A)
      39  #define BU U16_C (B)
      40  #define CU U16_C (C)
      41  #define DU U16_C (D)
      42  #define EU U16_C (E)
      43  #define FU U16_C (F)
      44  #define GU U16_C (G)
      45  #define HU U16_C (H)
      46  
      47  #define P16_C(a) ((poly16_t) a)
      48  #define AP P16_C (A)
      49  #define BP P16_C (B)
      50  #define CP P16_C (C)
      51  #define DP P16_C (D)
      52  #define EP P16_C (E)
      53  #define FP P16_C (F)
      54  #define GP P16_C (G)
      55  #define HP P16_C (H)
      56  
      57  /* Expected results for vduph_lane.  */
      58  float16_t expected_f16 = AF;
      59  int16_t expected_s16 = DS;
      60  uint16_t expected_u16 = BU;
      61  poly16_t expected_p16 = CP;
      62  
      63  /* Expected results for vduph_laneq.  */
      64  float16_t expected_q_f16 = EF;
      65  int16_t expected_q_s16 = BS;
      66  uint16_t expected_q_u16 = GU;
      67  poly16_t expected_q_p16 = FP;
      68  
      69  void exec_vduph_lane_f16 (void)
      70  {
      71    /* vduph_lane.  */
      72    DECL_VARIABLE(vsrc, float, 16, 4);
      73    DECL_VARIABLE(vsrc, int, 16, 4);
      74    DECL_VARIABLE(vsrc, uint, 16, 4);
      75    DECL_VARIABLE(vsrc, poly, 16, 4);
      76    VECT_VAR_DECL (buf_src, float, 16, 4) [] = {AF, BF, CF, DF};
      77    VECT_VAR_DECL (buf_src, int, 16, 4) [] = {AS, BS, CS, DS};
      78    VECT_VAR_DECL (buf_src, uint, 16, 4) [] = {AU, BU, CU, DU};
      79    VECT_VAR_DECL (buf_src, poly, 16, 4) [] = {AP, BP, CP, DP};
      80    VLOAD (vsrc, buf_src, , int, s, 16, 4);
      81    VLOAD (vsrc, buf_src, , float, f, 16, 4);
      82    VLOAD (vsrc, buf_src, , uint, u, 16, 4);
      83    VLOAD (vsrc, buf_src, , poly, p, 16, 4);
      84  
      85    float16_t res_f = vduph_lane_f16 (VECT_VAR (vsrc, float, 16, 4), 0);
      86    if (* (unsigned short *) &res_f != * (unsigned short *) &expected_f16)
      87      abort ();
      88  
      89    int16_t res_s = vduph_lane_s16 (VECT_VAR (vsrc, int, 16, 4), 3);
      90    if (* (unsigned short *) &res_s != * (unsigned short *) &expected_s16)
      91      abort ();
      92  
      93    uint16_t res_u = vduph_lane_u16 (VECT_VAR (vsrc, uint, 16, 4), 1);
      94    if (* (unsigned short *) &res_u != * (unsigned short *) &expected_u16)
      95      abort ();
      96  
      97    poly16_t res_p = vduph_lane_p16 (VECT_VAR (vsrc, poly, 16, 4), 2);
      98    if (* (unsigned short *) &res_p != * (unsigned short *) &expected_p16)
      99      abort ();
     100  
     101    /* vduph_laneq.  */
     102    DECL_VARIABLE(vsrc, float, 16, 8);
     103    DECL_VARIABLE(vsrc, int, 16, 8);
     104    DECL_VARIABLE(vsrc, uint, 16, 8);
     105    DECL_VARIABLE(vsrc, poly, 16, 8);
     106    VECT_VAR_DECL (buf_src, float, 16, 8) [] = {AF, BF, CF, DF, EF, FF, GF, HF};
     107    VECT_VAR_DECL (buf_src, int, 16, 8) [] = {AS, BS, CS, DS, ES, FS, GS, HS};
     108    VECT_VAR_DECL (buf_src, uint, 16, 8) [] = {AU, BU, CU, DU, EU, FU, GU, HU};
     109    VECT_VAR_DECL (buf_src, poly, 16, 8) [] = {AP, BP, CP, DP, EP, FP, GP, HP};
     110    VLOAD (vsrc, buf_src, q, int, s, 16, 8);
     111    VLOAD (vsrc, buf_src, q, float, f, 16, 8);
     112    VLOAD (vsrc, buf_src, q, uint, u, 16, 8);
     113    VLOAD (vsrc, buf_src, q, poly, p, 16, 8);
     114  
     115    res_f = vduph_laneq_f16 (VECT_VAR (vsrc, float, 16, 8), 4);
     116    if (* (unsigned short *) &res_f != * (unsigned short *) &expected_q_f16)
     117      abort ();
     118  
     119    res_s = vduph_laneq_s16 (VECT_VAR (vsrc, int, 16, 8), 1);
     120    if (* (unsigned short *) &res_s != * (unsigned short *) &expected_q_s16)
     121      abort ();
     122  
     123    res_u = vduph_laneq_u16 (VECT_VAR (vsrc, uint, 16, 8), 6);
     124    if (* (unsigned short *) &res_u != * (unsigned short *) &expected_q_u16)
     125      abort ();
     126  
     127    res_p = vduph_laneq_p16 (VECT_VAR (vsrc, poly, 16, 8), 5);
     128    if (* (unsigned short *) &res_p != * (unsigned short *) &expected_q_p16)
     129      abort ();
     130  }
     131  
     132  int
     133  main (void)
     134  {
     135    exec_vduph_lane_f16 ();
     136    return 0;
     137  }