1  /* { dg-skip-if "" { arm*-*-* } } */
       2  
       3  #include <arm_neon.h>
       4  #include "arm-neon-ref.h"
       5  #include "compute-ref-data.h"
       6  
       7  /* Expected results.  */
       8  VECT_VAR_DECL(expected, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5,
       9  					    0x5, 0x5, 0x5, 0x5,
      10  					    0x34, 0x34, 0x34, 0x34,
      11  					    0x34, 0x34, 0x34, 0x34 };
      12  VECT_VAR_DECL(expected, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5,
      13  					    0x5678, 0x5678, 0x5678, 0x5678 };
      14  VECT_VAR_DECL(expected, uint, 32, 4) [] = { 0x5, 0x5, 0x12345678, 0x12345678 };
      15  
      16  /* Expected results with negative input.  */
      17  VECT_VAR_DECL(expected_neg, uint, 8, 16) [] = { 0x5, 0x5, 0x5, 0x5,
      18  						0x5, 0x5, 0x5, 0x5,
      19  						0x0, 0x0, 0x0, 0x0,
      20  						0x0, 0x0, 0x0, 0x0 };
      21  VECT_VAR_DECL(expected_neg, uint, 16, 8) [] = { 0x5, 0x5, 0x5, 0x5,
      22  						0x0, 0x0, 0x0, 0x0 };
      23  VECT_VAR_DECL(expected_neg, uint, 32, 4) [] = { 0x5, 0x5, 0x0, 0x0 };
      24  
      25  #define TEST_MSG "VQMOVUN_HIGH"
      26  void exec_vqmovun_high (void)
      27  {
      28    /* Basic test: vec128_r=vqmovun_high(vec64)_r, vec128_x), store result.  */
      29  #define TEST_VQMOVUN_HIGH(T1, T2, W1, W2, N1, N2, CMT)				\
      30    Set_Neon_Cumulative_Sat(0, VECT_VAR(vec128_r, T1, W1, N2));			\
      31    VECT_VAR(vec128_r, T1, W1, N2) =						\
      32      vqmovun_high_s##W2(VECT_VAR(vec64_r, uint, W1, N1),				\
      33  		       VECT_VAR(vec128_x, int, W2, N1));			\
      34    vst1q##_u##W1(VECT_VAR(result, T1, W1, N2), VECT_VAR(vec128_r, T1, W1, N2))
      35  
      36    DECL_VARIABLE(vec64_r, uint, 8, 8);
      37    DECL_VARIABLE(vec64_r, uint, 16, 4);
      38    DECL_VARIABLE(vec64_r, uint, 32, 2);
      39  
      40    DECL_VARIABLE(vec128_x, int, 16, 8);
      41    DECL_VARIABLE(vec128_x, int, 32, 4);
      42    DECL_VARIABLE(vec128_x, int, 64, 2);
      43  
      44    DECL_VARIABLE(vec128_r, uint, 8, 16);
      45    DECL_VARIABLE(vec128_r, uint, 16, 8);
      46    DECL_VARIABLE(vec128_r, uint, 32, 4);
      47  
      48    clean_results ();
      49  
      50    /* Fill vec64_r with a value easy to recognise in the result vector. */
      51    VDUP(vec64_r, , uint, u, 8, 8, 0x5);
      52    VDUP(vec64_r, , uint, u, 16, 4, 0x5);
      53    VDUP(vec64_r, , uint, u, 32, 2, 0x5);
      54  
      55    /* Fill input vector with arbitrary values.  */
      56    VDUP(vec128_x, q, int, s, 16, 8, 0x34);
      57    VDUP(vec128_x, q, int, s, 32, 4, 0x5678);
      58    VDUP(vec128_x, q, int, s, 64, 2, 0x12345678);
      59  
      60  
      61  #define CMT ""
      62    TEST_VQMOVUN_HIGH(uint, u, 8, 16, 8, 16, CMT);
      63    TEST_VQMOVUN_HIGH(uint, u, 16, 32, 4, 8, CMT);
      64    TEST_VQMOVUN_HIGH(uint, u, 32, 64, 2, 4, CMT);
      65  
      66    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, CMT);
      67    CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, CMT);
      68    CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, CMT);
      69  
      70    /* Fill input vector with negative values.  */
      71    VDUP(vec128_x, q, int, s, 16, 8, 0x8234);
      72    VDUP(vec128_x, q, int, s, 32, 4, 0x87654321);
      73    VDUP(vec128_x, q, int, s, 64, 2, 0x8765432187654321LL);
      74  
      75  
      76  #undef CMT
      77  #define CMT " (negative input)"
      78    TEST_VQMOVUN_HIGH(uint, u, 8, 16, 8, 16, CMT);
      79    TEST_VQMOVUN_HIGH(uint, u, 16, 32, 4, 8, CMT);
      80    TEST_VQMOVUN_HIGH(uint, u, 32, 64, 2, 4, CMT);
      81  
      82    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected_neg, CMT);
      83    CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected_neg, CMT);
      84    CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected_neg, CMT);
      85  }
      86  
      87  int main (void)
      88  {
      89    exec_vqmovun_high ();
      90    return 0;
      91  }