(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
aarch64/
advsimd-intrinsics/
vabd.c
       1  #include <arm_neon.h>
       2  #include "arm-neon-ref.h"
       3  #include "compute-ref-data.h"
       4  #include <math.h>
       5  
       6  /* Expected results.  */
       7  VECT_VAR_DECL(expected,int,8,8) [] = { 0x11, 0x10, 0xf, 0xe,
       8  				       0xd, 0xc, 0xb, 0xa };
       9  VECT_VAR_DECL(expected,int,16,4) [] = { 0x3, 0x2, 0x1, 0x0 };
      10  VECT_VAR_DECL(expected,int,32,2) [] = { 0x18, 0x17 };
      11  VECT_VAR_DECL(expected,uint,8,8) [] = { 0xef, 0xf0, 0xf1, 0xf2,
      12  					0xf3, 0xf4, 0xf5, 0xf6 };
      13  VECT_VAR_DECL(expected,uint,16,4) [] = { 0xffe3, 0xffe4, 0xffe5, 0xffe6 };
      14  VECT_VAR_DECL(expected,uint,32,2) [] = { 0xffffffe8, 0xffffffe9 };
      15  VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x41c26666, 0x41ba6666 };
      16  VECT_VAR_DECL(expected,int,8,16) [] = { 0x1a, 0x19, 0x18, 0x17,
      17  					0x16, 0x15, 0x14, 0x13,
      18  					0x12, 0x11, 0x10, 0xf,
      19  					0xe, 0xd, 0xc, 0xb };
      20  VECT_VAR_DECL(expected,int,16,8) [] = { 0x4, 0x3, 0x2, 0x1,
      21  					0x0, 0x1, 0x2, 0x3 };
      22  VECT_VAR_DECL(expected,int,32,4) [] = { 0x30, 0x2f, 0x2e, 0x2d };
      23  VECT_VAR_DECL(expected,uint,8,16) [] = { 0xe6, 0xe7, 0xe8, 0xe9,
      24  					 0xea, 0xeb, 0xec, 0xed,
      25  					 0xee, 0xef, 0xf0, 0xf1,
      26  					 0xf2, 0xf3, 0xf4, 0xf5 };
      27  VECT_VAR_DECL(expected,uint,16,8) [] = { 0xffe4, 0xffe5, 0xffe6, 0xffe7,
      28  					 0xffe8, 0xffe9, 0xffea, 0xffeb };
      29  VECT_VAR_DECL(expected,uint,32,4) [] = { 0xffffffd0, 0xffffffd1,
      30  					 0xffffffd2, 0xffffffd3 };
      31  VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0x42407ae1, 0x423c7ae1,
      32  					   0x42387ae1, 0x42347ae1 };
      33  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
      34  VECT_VAR_DECL(expected, hfloat, 16, 4) [] = { 0x4e13, 0x4dd3,
      35  					      0x4d93, 0x4d53 };
      36  VECT_VAR_DECL(expected, hfloat, 16, 8) [] = { 0x5204, 0x51e4, 0x51c4, 0x51a4,
      37  					      0x5184, 0x5164, 0x5144, 0x5124 };
      38  #endif
      39  
      40  /* Additional expected results for float32 variants with specially
      41     chosen input values.  */
      42  VECT_VAR_DECL(expected_float32,hfloat,32,4) [] = { 0x0, 0x0, 0x0, 0x0 };
      43  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
      44  VECT_VAR_DECL(expected_float16, hfloat, 16, 8) [] = { 0x0, 0x0, 0x0, 0x0,
      45  						      0x0, 0x0, 0x0, 0x0 };
      46  #endif
      47  
      48  #define TEST_MSG "VABD/VABDQ"
      49  void exec_vabd (void)
      50  {
      51    /* Basic test: v4=vabd(v1,v2), then store the result.  */
      52  #define TEST_VABD(Q, T1, T2, W, N)					\
      53    VECT_VAR(vector_res, T1, W, N) =					\
      54      vabd##Q##_##T2##W(VECT_VAR(vector1, T1, W, N),			\
      55  		      VECT_VAR(vector2, T1, W, N));			\
      56    vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
      57  
      58  #define DECL_VABD_VAR(VAR)			\
      59    DECL_VARIABLE(VAR, int, 8, 8);		\
      60    DECL_VARIABLE(VAR, int, 16, 4);		\
      61    DECL_VARIABLE(VAR, int, 32, 2);		\
      62    DECL_VARIABLE(VAR, uint, 8, 8);		\
      63    DECL_VARIABLE(VAR, uint, 16, 4);		\
      64    DECL_VARIABLE(VAR, uint, 32, 2);		\
      65    DECL_VARIABLE(VAR, float, 32, 2);		\
      66    DECL_VARIABLE(VAR, int, 8, 16);		\
      67    DECL_VARIABLE(VAR, int, 16, 8);		\
      68    DECL_VARIABLE(VAR, int, 32, 4);		\
      69    DECL_VARIABLE(VAR, uint, 8, 16);		\
      70    DECL_VARIABLE(VAR, uint, 16, 8);		\
      71    DECL_VARIABLE(VAR, uint, 32, 4);		\
      72    DECL_VARIABLE(VAR, float, 32, 4)
      73  
      74    DECL_VABD_VAR(vector1);
      75    DECL_VABD_VAR(vector2);
      76    DECL_VABD_VAR(vector_res);
      77  
      78  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
      79    DECL_VARIABLE(vector1, float, 16, 4);
      80    DECL_VARIABLE(vector1, float, 16, 8);
      81  
      82    DECL_VARIABLE(vector2, float, 16, 4);
      83    DECL_VARIABLE(vector2, float, 16, 8);
      84  
      85    DECL_VARIABLE(vector_res, float, 16, 4);
      86    DECL_VARIABLE(vector_res, float, 16, 8);
      87  #endif
      88  
      89    clean_results ();
      90  
      91    /* Initialize input "vector1" from "buffer".  */
      92    VLOAD(vector1, buffer, , int, s, 8, 8);
      93    VLOAD(vector1, buffer, , int, s, 16, 4);
      94    VLOAD(vector1, buffer, , int, s, 32, 2);
      95    VLOAD(vector1, buffer, , uint, u, 8, 8);
      96    VLOAD(vector1, buffer, , uint, u, 16, 4);
      97    VLOAD(vector1, buffer, , uint, u, 32, 2);
      98    VLOAD(vector1, buffer, , float, f, 32, 2);
      99    VLOAD(vector1, buffer, q, int, s, 8, 16);
     100    VLOAD(vector1, buffer, q, int, s, 16, 8);
     101    VLOAD(vector1, buffer, q, int, s, 32, 4);
     102    VLOAD(vector1, buffer, q, uint, u, 8, 16);
     103    VLOAD(vector1, buffer, q, uint, u, 16, 8);
     104    VLOAD(vector1, buffer, q, uint, u, 32, 4);
     105    VLOAD(vector1, buffer, q, float, f, 32, 4);
     106  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     107    VLOAD(vector1, buffer, , float, f, 16, 4);
     108    VLOAD(vector1, buffer, , float, f, 16, 4);
     109    VLOAD(vector1, buffer, q, float, f, 16, 8);
     110    VLOAD(vector1, buffer, q, float, f, 16, 8);
     111  #endif
     112  
     113    /* Choose init value arbitrarily.  */
     114    VDUP(vector2, , int, s, 8, 8, 1);
     115    VDUP(vector2, , int, s, 16, 4, -13);
     116    VDUP(vector2, , int, s, 32, 2, 8);
     117    VDUP(vector2, , uint, u, 8, 8, 1);
     118    VDUP(vector2, , uint, u, 16, 4, 13);
     119    VDUP(vector2, , uint, u, 32, 2, 8);
     120    VDUP(vector2, , float, f, 32, 2, 8.3f);
     121    VDUP(vector2, q, int, s, 8, 16, 10);
     122    VDUP(vector2, q, int, s, 16, 8, -12);
     123    VDUP(vector2, q, int, s, 32, 4, 32);
     124    VDUP(vector2, q, uint, u, 8, 16, 10);
     125    VDUP(vector2, q, uint, u, 16, 8, 12);
     126    VDUP(vector2, q, uint, u, 32, 4, 32);
     127    VDUP(vector2, q, float, f, 32, 4, 32.12f);
     128  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     129    VDUP(vector2, , float, f, 16, 4, 8.3f);
     130    VDUP(vector2, q, float, f, 16, 8, 32.12f);
     131  #endif
     132  
     133    /* Execute the tests.  */
     134    TEST_VABD(, int, s, 8, 8);
     135    TEST_VABD(, int, s, 16, 4);
     136    TEST_VABD(, int, s, 32, 2);
     137    TEST_VABD(, uint, u, 8, 8);
     138    TEST_VABD(, uint, u, 16, 4);
     139    TEST_VABD(, uint, u, 32, 2);
     140    TEST_VABD(, float, f, 32, 2);
     141    TEST_VABD(q, int, s, 8, 16);
     142    TEST_VABD(q, int, s, 16, 8);
     143    TEST_VABD(q, int, s, 32, 4);
     144    TEST_VABD(q, uint, u, 8, 16);
     145    TEST_VABD(q, uint, u, 16, 8);
     146    TEST_VABD(q, uint, u, 32, 4);
     147    TEST_VABD(q, float, f, 32, 4);
     148  
     149  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     150    TEST_VABD(, float, f, 16, 4);
     151    TEST_VABD(q, float, f, 16, 8);
     152  #endif
     153  
     154    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
     155    CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
     156    CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
     157    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, "");
     158    CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, "");
     159    CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
     160    CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, "");
     161    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
     162    CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
     163    CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
     164    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, "");
     165    CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, "");
     166    CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
     167    CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, "");
     168  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     169    CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected, "");
     170    CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected, "");
     171  #endif
     172  
     173    /* Extra FP tests with special values (-0.0, ....) */
     174    VDUP(vector1, q, float, f, 32, 4, -0.0f);
     175    VDUP(vector2, q, float, f, 32, 4, 0.0);
     176    TEST_VABD(q, float, f, 32, 4);
     177    CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_float32, " FP special (-0.0)");
     178  
     179  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     180    VDUP(vector1, q, float, f, 16, 8, -0.0f);
     181    VDUP(vector2, q, float, f, 16, 8, 0.0);
     182    TEST_VABD(q, float, f, 16, 8);
     183    CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_float16,
     184  	   " FP special (-0.0)");
     185  #endif
     186  
     187    /* Extra FP tests with special values (-0.0, ....) */
     188    VDUP(vector1, q, float, f, 32, 4, 0.0f);
     189    VDUP(vector2, q, float, f, 32, 4, -0.0);
     190    TEST_VABD(q, float, f, 32, 4);
     191    CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected_float32, " FP special (-0.0)");
     192  
     193  #if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
     194    VDUP(vector1, q, float, f, 16, 8, 0.0f);
     195    VDUP(vector2, q, float, f, 16, 8, -0.0);
     196    TEST_VABD(q, float, f, 16, 8);
     197    CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected_float16,
     198  	   " FP special (-0.0)");
     199  #endif
     200  }
     201  
     202  int main (void)
     203  {
     204    exec_vabd ();
     205    return 0;
     206  }