(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
ssse3-pabsw.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O3 -mpower8-vector -Wno-psabi" } */
       3  /* { dg-require-effective-target p8vector_hw } */
       4  
       5  #ifndef CHECK_H
       6  #define CHECK_H "ssse3-check.h"
       7  #endif
       8  
       9  #ifndef TEST
      10  #define TEST ssse3_test
      11  #endif
      12  
      13  #include CHECK_H
      14  
      15  #include "ssse3-vals.h"
      16  
      17  #include <tmmintrin.h>
      18  
      19  #ifndef __AVX__
      20  /* Test the 64-bit form */
      21  static void
      22  ssse3_test_pabsw (__m64 *i1, __m64 *r)
      23  {
      24    *r = _mm_abs_pi16 (*i1);
      25    _mm_empty ();
      26  }
      27  #endif
      28  
      29  /* Test the 128-bit form */
      30  static void
      31  ssse3_test_pabsw128 (__m128i *i1, __m128i *r)
      32  {
      33    /* Assumes incoming pointers are 16-byte aligned */
      34    *r = _mm_abs_epi16 (*i1);
      35  }
      36  
      37  /* Routine to manually compute the results */
      38  static void
      39  compute_correct_result (short *i1, short *r)
      40  {
      41    int i;
      42  
      43    for (i = 0; i < 8; i++)
      44      if (i1[i] < 0)
      45        r[i] = -i1[i];
      46      else
      47        r[i] = i1[i];
      48  }
      49  
      50  static void
      51  TEST (void)
      52  {
      53    int i;
      54    union data r __attribute__ ((aligned(16)));
      55    union data ck;
      56    int fail = 0;
      57  
      58    for (i = 0; i < ARRAY_SIZE (vals); i++)
      59      {
      60        /* Manually compute the result */
      61        compute_correct_result (&vals[i].h[0], &ck.h[0]);
      62  
      63  #ifndef __AVX__
      64        /* Run the 64-bit tests */
      65        ssse3_test_pabsw (&vals[i].ll[0], &r.ll[0]);
      66        ssse3_test_pabsw (&vals[i].ll[1], &r.ll[1]);
      67        fail += chk_128 (ck.m[0], r.m[0]);
      68  #endif
      69  
      70        /* Run the 128-bit tests */
      71        ssse3_test_pabsw128 (&vals[i].m[0], &r.m[0]);
      72        fail += chk_128 (ck.m[0], r.m[0]);
      73      }
      74    
      75    if (fail != 0)
      76      abort ();
      77  }