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 "sse2-check.h"
       7  #endif
       8  
       9  #include CHECK_H
      10  
      11  #ifndef TEST
      12  #define TEST sse2_test_packssdw_1
      13  #endif
      14  
      15  #include <emmintrin.h>
      16  
      17  static __m128i
      18  __attribute__((noinline, unused))
      19  test (__m128i s1, __m128i s2)
      20  {
      21    __asm("" : "+v"(s1), "+v"(s2));
      22    return _mm_packs_epi32 (s1, s2); 
      23  }
      24  
      25  static void
      26  TEST (void)
      27  {
      28    union128i_d s1, s2;
      29    union128i_w u;
      30    short e[8];
      31    int i;
      32     
      33    s1.x = _mm_set_epi32 (2134, -128, 655366, 9999);
      34    s2.x = _mm_set_epi32 (41124, 234, 2, -800900);
      35    u.x = test (s1.x, s2.x); 
      36  
      37    for (i = 0; i < 4; i++)
      38      {
      39        if (s1.a[i] > 32767)
      40          e[i] = 32767;
      41        else if (s1.a[i] < -32768)
      42          e[i] = -32768;
      43        else
      44          e[i] = s1.a[i];
      45      }
      46    
      47    for (i = 0; i < 4; i++)
      48     {
      49        if (s2.a[i] > 32767)
      50          e[i+4] = 32767;
      51        else if (s2.a[i] < -32768)
      52          e[i+4] = -32768;
      53        else
      54          e[i+4] = s2.a[i];
      55      }
      56  
      57    if (check_union128i_w (u, e))
      58      {
      59  #if DEBUG
      60        printf ("sse2_test_packssdw_1; check_union128i_w failed\n");
      61        printf ("\t ([%x,%x,%x,%x], [%x,%x,%x,%x])"
      62  	      " -> [%x,%x,%x,%x, %x,%x,%x,%x]\n",
      63  	      s1.a[0], s1.a[1], s1.a[2], s1.a[3], s2.a[0], s2.a[1], s2.a[2],
      64  	      s2.a[3], u.a[0], u.a[1], u.a[2], u.a[3], u.a[4], u.a[5], u.a[6],
      65  	      u.a[7]);
      66        printf ("\t expect [%x,%x,%x,%x, %x,%x,%x,%x]\n", e[0], e[1], e[2], e[3],
      67  	      e[4], e[5], e[6], e[7]);
      68  #endif
      69        abort ();
      70      }
      71  }