(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
ssse3-phsubw.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  #include "ssse3-vals.h"
      15  
      16  #include <tmmintrin.h>
      17  
      18  #ifndef __AVX__
      19  /* Test the 64-bit form */
      20  static void
      21  ssse3_test_phsubw (__m64 *i1, __m64 *i2, __m64 *r)
      22  {
      23    *(__m64 *) r = _mm_hsub_pi16 (*i1, *i2);
      24    _mm_empty ();
      25  }
      26  #endif
      27  
      28  /* Test the 128-bit form */
      29  static void
      30  ssse3_test_phsubw128 (__m128i *i1, __m128i *i2, __m128i *r)
      31  {
      32    /* Assumes incoming pointers are 16-byte aligned */
      33    *(__m128i *) r = _mm_hsub_epi16 (*i1, *i2);
      34  }
      35  
      36  /* Routine to manually compute the results */
      37  static void
      38  compute_correct_result (short *i1, short *i2, short *r)
      39  {
      40    int i;
      41  
      42    for (i = 0; i < 4; i++)
      43      r[i] = i1[2 * i] - i1[2 * i + 1];
      44    for (i = 0; i < 4; i++)
      45      r[i + 4] = i2[2 * i] - i2[2 * i + 1];
      46  }
      47  
      48  static void
      49  TEST (void)
      50  {
      51    int i;
      52    union data r __attribute__ ((aligned(16)));
      53    union data ck;
      54    int fail = 0;
      55  
      56    for (i = 0; i < ARRAY_SIZE (vals) - 1; i++)
      57      {
      58        /* Manually compute the result */
      59        compute_correct_result (&vals[i + 0].h[0], &vals[i + 1].h[0], &ck.h[0]);
      60  
      61  #ifndef __AVX__
      62        /* Run the 64-bit tests */
      63        ssse3_test_phsubw (&vals[i + 0].ll[0], &vals[i + 0].ll[1], &r.ll[0]);
      64        ssse3_test_phsubw (&vals[i + 1].ll[0], &vals[i + 1].ll[1], &r.ll[1]);
      65        fail += chk_128 (ck.m[0], r.m[0]);
      66  #endif
      67  
      68        /* Run the 128-bit tests */
      69        ssse3_test_phsubw128 (&vals[i + 0].m[0], &vals[i + 1].m[0], &r.m[0]);
      70        fail += chk_128 (ck.m[0], r.m[0]);
      71      }
      72  
      73    if (fail != 0)
      74      abort ();
      75  }