(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
advsimd-intrinsics/
vabal.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,8) [] = { 0xfff6, 0xfff7, 0xfff8, 0xfff9,
       7  					0xfffa, 0xfffb, 0xfffc, 0xfffd };
       8  VECT_VAR_DECL(expected,int,32,4) [] = { 0x16, 0x17, 0x18, 0x19 };
       9  VECT_VAR_DECL(expected,int,64,2) [] = { 0x20, 0x21 };
      10  VECT_VAR_DECL(expected,uint,16,8) [] = { 0x53, 0x54, 0x55, 0x56,
      11  					 0x57, 0x58, 0x59, 0x5a };
      12  VECT_VAR_DECL(expected,uint,32,4) [] = { 0x907, 0x908, 0x909, 0x90a };
      13  VECT_VAR_DECL(expected,uint,64,2) [] = { 0xffffffe7,
      14  					 0xffffffe8 };
      15  
      16  /* Expected results for cases with input values chosen to test
      17     possible intermediate overflow.  */
      18  VECT_VAR_DECL(expected2,int,16,8) [] = { 0xef, 0xf0, 0xf1, 0xf2,
      19  					 0xf3, 0xf4, 0xf5, 0xf6 };
      20  VECT_VAR_DECL(expected2,int,32,4) [] = { 0xffef, 0xfff0, 0xfff1, 0xfff2 };
      21  VECT_VAR_DECL(expected2,int,64,2) [] = { 0xffffffef, 0xfffffff0 };
      22  VECT_VAR_DECL(expected2,uint,16,8) [] = { 0xee, 0xef, 0xf0, 0xf1,
      23  					  0xf2, 0xf3, 0xf4, 0xf5 };
      24  VECT_VAR_DECL(expected2,uint,32,4) [] = { 0xffe2, 0xffe3, 0xffe4, 0xffe5 };
      25  VECT_VAR_DECL(expected2,uint,64,2) [] = { 0xffffffe7, 0xffffffe8 };
      26  
      27  #define TEST_MSG "VABAL"
      28  void exec_vabal (void)
      29  {
      30    /* Basic test: v4=vabal(v1,v2,v3), then store the result.  */
      31  #define TEST_VABAL(T1, T2, W, W2, N)					\
      32    VECT_VAR(vector_res, T1, W2, N) =					\
      33      vabal_##T2##W(VECT_VAR(vector1, T1, W2, N),				\
      34  		  VECT_VAR(vector2, T1, W, N),				\
      35  		  VECT_VAR(vector3, T1, W, N));				\
      36    vst1q_##T2##W2(VECT_VAR(result, T1, W2, N), VECT_VAR(vector_res, T1, W2, N))
      37  
      38  #define DECL_VABAL_VAR_LONG(VAR)		\
      39    DECL_VARIABLE(VAR, int, 16, 8);		\
      40    DECL_VARIABLE(VAR, int, 32, 4);		\
      41    DECL_VARIABLE(VAR, int, 64, 2);		\
      42    DECL_VARIABLE(VAR, uint, 16, 8);		\
      43    DECL_VARIABLE(VAR, uint, 32, 4);		\
      44    DECL_VARIABLE(VAR, uint, 64, 2)
      45  
      46  #define DECL_VABAL_VAR_SHORT(VAR)		\
      47    DECL_VARIABLE(VAR, int, 8, 8);		\
      48    DECL_VARIABLE(VAR, int, 16, 4);		\
      49    DECL_VARIABLE(VAR, int, 32, 2);		\
      50    DECL_VARIABLE(VAR, uint, 8, 8);		\
      51    DECL_VARIABLE(VAR, uint, 16, 4);		\
      52    DECL_VARIABLE(VAR, uint, 32, 2)
      53  
      54    DECL_VABAL_VAR_LONG(vector1);
      55    DECL_VABAL_VAR_SHORT(vector2);
      56    DECL_VABAL_VAR_SHORT(vector3);
      57    DECL_VABAL_VAR_LONG(vector_res);
      58  
      59    clean_results ();
      60  
      61    /* Initialize input "vector1" from "buffer".  */
      62    VLOAD(vector1, buffer, q, int, s, 16, 8);
      63    VLOAD(vector1, buffer, q, int, s, 32, 4);
      64    VLOAD(vector1, buffer, q, int, s, 64, 2);
      65    VLOAD(vector1, buffer, q, uint, u, 16, 8);
      66    VLOAD(vector1, buffer, q, uint, u, 32, 4);
      67    VLOAD(vector1, buffer, q, uint, u, 64, 2);
      68  
      69  
      70    /* Choose init value arbitrarily.  */
      71    VDUP(vector2, , int, s, 8, 8, 1);
      72    VDUP(vector2, , int, s, 16, 4, -13);
      73    VDUP(vector2, , int, s, 32, 2, 8);
      74    VDUP(vector2, , uint, u, 8, 8, 1);
      75    VDUP(vector2, , uint, u, 16, 4, 13);
      76    VDUP(vector2, , uint, u, 32, 2, 8);
      77  
      78    /* Choose init value arbitrarily.  */
      79    VDUP(vector3, , int, s, 8, 8, -5);
      80    VDUP(vector3, , int, s, 16, 4, 25);
      81    VDUP(vector3, , int, s, 32, 2, -40);
      82    VDUP(vector3, , uint, u, 8, 8, 100);
      83    VDUP(vector3, , uint, u, 16, 4, 2340);
      84    VDUP(vector3, , uint, u, 32, 2, 0xffffffff);
      85  
      86    /* Execute the tests.  */
      87    TEST_VABAL(int, s, 8, 16, 8);
      88    TEST_VABAL(int, s, 16, 32, 4);
      89    TEST_VABAL(int, s, 32, 64, 2);
      90    TEST_VABAL(uint, u, 8, 16, 8);
      91    TEST_VABAL(uint, u, 16, 32, 4);
      92    TEST_VABAL(uint, u, 32, 64, 2);
      93  
      94    CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
      95    CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
      96    CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, "");
      97    CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, "");
      98    CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
      99    CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, "");
     100  
     101    /* Use values that could lead to overflow intermediate
     102     * calculations.  */
     103    VDUP(vector2, , int, s, 8, 8, 0x80);
     104    VDUP(vector2, , int, s, 16, 4, 0x8000);
     105    VDUP(vector2, , int, s, 32, 2, 0x80000000);
     106    VDUP(vector2, , uint, u, 8, 8, 1);
     107    VDUP(vector2, , uint, u, 16, 4, 13);
     108    VDUP(vector2, , uint, u, 32, 2, 8);
     109  
     110    VDUP(vector3, , int, s, 8, 8, 0x7f);
     111    VDUP(vector3, , int, s, 16, 4, 0x7fff);
     112    VDUP(vector3, , int, s, 32, 2, 0x7fffffff);
     113    VDUP(vector3, , uint, u, 8, 8, 0xff);
     114    VDUP(vector3, , uint, u, 16, 4, 0xffff);
     115    VDUP(vector3, , uint, u, 32, 2, 0xffffffff);
     116  
     117    TEST_VABAL(int, s, 8, 16, 8);
     118    TEST_VABAL(int, s, 16, 32, 4);
     119    TEST_VABAL(int, s, 32, 64, 2);
     120    TEST_VABAL(uint, u, 8, 16, 8);
     121    TEST_VABAL(uint, u, 16, 32, 4);
     122    TEST_VABAL(uint, u, 32, 64, 2);
     123  
     124    CHECK(TEST_MSG, int, 16, 8, PRIx16, expected2, " test intermediate overflow");
     125    CHECK(TEST_MSG, int, 32, 4, PRIx32, expected2, " test intermediate overflow");
     126    CHECK(TEST_MSG, int, 64, 2, PRIx64, expected2, " test intermediate overflow");
     127    CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected2, " test intermediate overflow");
     128    CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected2, " test intermediate overflow");
     129    CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected2, " test intermediate overflow");
     130  }
     131  
     132  int main (void)
     133  {
     134    exec_vabal ();
     135    return 0;
     136  }