(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
advsimd-intrinsics/
vqdmulh_lane.c
       1  #include <arm_neon.h>
       2  #include "arm-neon-ref.h"
       3  #include "compute-ref-data.h"
       4  
       5  /* Expected results.  */
       6  VECT_VAR_DECL(expected,int,16,4) [] = { 0xffff, 0xffff, 0xffff, 0xffff };
       7  VECT_VAR_DECL(expected,int,32,2) [] = { 0xffffffff, 0xffffffff };
       8  VECT_VAR_DECL(expected,int,16,8) [] = { 0xffff, 0xffff, 0xffff, 0xffff,
       9  					0xffff, 0xffff, 0xffff, 0xffff };
      10  VECT_VAR_DECL(expected,int,32,4) [] = { 0xffffffff, 0xffffffff,
      11  					0xffffffff, 0xffffffff };
      12  
      13  /* Expected results when saturation occurs.  */
      14  VECT_VAR_DECL(expected2,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff };
      15  VECT_VAR_DECL(expected2,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
      16  VECT_VAR_DECL(expected2,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff,
      17  					0x7fff, 0x7fff, 0x7fff, 0x7fff };
      18  VECT_VAR_DECL(expected2,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
      19  					0x7fffffff, 0x7fffffff };
      20  
      21  #define INSN_NAME vqdmulh
      22  #define TEST_MSG "VQDMULH_LANE"
      23  #define FNNAME1(NAME) exec_ ## NAME ## _lane
      24  #define FNNAME(NAME) FNNAME1(NAME)
      25  
      26  void FNNAME (INSN_NAME) (void)
      27  {
      28    /* vector_res = vqdmulh_lane(vector,vector2,lane), then store the result.  */
      29  #define TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L, CMT) \
      30    Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N));		\
      31    VECT_VAR(vector_res, T1, W, N) =					\
      32      INSN##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N),			\
      33  			   VECT_VAR(vector2, T1, W, N2),		\
      34  			   L);						\
      35    vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
      36  		    VECT_VAR(vector_res, T1, W, N))
      37  
      38    /* Two auxliary macros are necessary to expand INSN.  */
      39  #define TEST_VQDMULH_LANE1(INSN, Q, T1, T2, W, N, N2, L, CMT) \
      40    TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L, CMT)
      41  
      42  #define TEST_VQDMULH_LANE(Q, T1, T2, W, N, N2, L, CMT) \
      43    TEST_VQDMULH_LANE1(INSN_NAME, Q, T1, T2, W, N, N2, L, CMT)
      44  
      45    DECL_VARIABLE(vector, int, 16, 4);
      46    DECL_VARIABLE(vector, int, 32, 2);
      47    DECL_VARIABLE(vector, int, 16, 8);
      48    DECL_VARIABLE(vector, int, 32, 4);
      49  
      50    DECL_VARIABLE(vector_res, int, 16, 4);
      51    DECL_VARIABLE(vector_res, int, 32, 2);
      52    DECL_VARIABLE(vector_res, int, 16, 8);
      53    DECL_VARIABLE(vector_res, int, 32, 4);
      54  
      55    /* vector2: vqdmulh_lane and vqdmulhq_lane have a 2nd argument with
      56       the same number of elements, so we need only one variable of each
      57       type.  */
      58    DECL_VARIABLE(vector2, int, 16, 4);
      59    DECL_VARIABLE(vector2, int, 32, 2);
      60  
      61    clean_results ();
      62  
      63    VLOAD(vector, buffer, , int, s, 16, 4);
      64    VLOAD(vector, buffer, , int, s, 32, 2);
      65    VLOAD(vector, buffer, q, int, s, 16, 8);
      66    VLOAD(vector, buffer, q, int, s, 32, 4);
      67  
      68    /* Initialize vector2.  */
      69    VDUP(vector2, , int, s, 16, 4, 0x55);
      70    VDUP(vector2, , int, s, 32, 2, 0xBB);
      71  
      72    /* Choose lane arbitrarily.  */
      73    TEST_VQDMULH_LANE(, int, s, 16, 4, 4, 2, "");
      74    TEST_VQDMULH_LANE(, int, s, 32, 2, 2, 1, "");
      75    TEST_VQDMULH_LANE(q, int, s, 16, 8, 4, 3, "");
      76    TEST_VQDMULH_LANE(q, int, s, 32, 4, 2, 0, "");
      77  
      78    CHECK (TEST_MSG, int, 16, 4, PRIx16, expected, "");
      79    CHECK (TEST_MSG, int, 32, 2, PRIx32, expected, "");
      80    CHECK (TEST_MSG, int, 16, 8, PRIx16, expected, "");
      81    CHECK (TEST_MSG, int, 32, 4, PRIx32, expected, "");
      82  
      83    /* Choose input values to trigger saturation.  */
      84    VDUP(vector, , int, s, 16, 4, 0x8000);
      85    VDUP(vector, , int, s, 32, 2, 0x80000000);
      86    VDUP(vector, q, int, s, 16, 8, 0x8000);
      87    VDUP(vector, q, int, s, 32, 4, 0x80000000);
      88    VDUP(vector2, , int, s, 16, 4, 0x8000);
      89    VDUP(vector2, , int, s, 32, 2, 0x80000000);
      90  
      91  #define TEST_MSG2 " (check mul cumulative saturation)"
      92    TEST_VQDMULH_LANE(, int, s, 16, 4, 4, 3, TEST_MSG2);
      93    TEST_VQDMULH_LANE(, int, s, 32, 2, 2, 1, TEST_MSG2);
      94    TEST_VQDMULH_LANE(q, int, s, 16, 8, 4, 2, TEST_MSG2);
      95    TEST_VQDMULH_LANE(q, int, s, 32, 4, 2, 1, TEST_MSG2);
      96  
      97    CHECK (TEST_MSG, int, 16, 4, PRIx16, expected2, TEST_MSG2);
      98    CHECK (TEST_MSG, int, 32, 2, PRIx32, expected2, TEST_MSG2);
      99    CHECK (TEST_MSG, int, 16, 8, PRIx16, expected2, TEST_MSG2);
     100    CHECK (TEST_MSG, int, 32, 4, PRIx32, expected2, TEST_MSG2);
     101  }
     102  
     103  int main (void)
     104  {
     105    FNNAME (INSN_NAME) ();
     106    return 0;
     107  }