1  /* { dg-do run } */
       2  /* { dg-options "-O2 -msse2 -mno-sse3" } */
       3  /* { dg-require-effective-target sse2 } */
       4  
       5  #ifndef CHECK_H
       6  #define CHECK_H "sse2-check.h"
       7  #endif
       8  
       9  #ifndef TEST
      10  #define TEST sse2_test
      11  #endif
      12  
      13  #include CHECK_H
      14  
      15  typedef long long V __attribute__((vector_size (16)));
      16  
      17  #define TESTN(N) \
      18  static V			\
      19  __attribute__((noipa))		\
      20  test##N (V x)			\
      21  {				\
      22    return x >> N;		\
      23  }
      24  
      25  #define TESTS TESTN (63) TESTN (49) TESTN (32) TESTN (31) TESTN (18)
      26  TESTS
      27  
      28  struct
      29  {
      30    int n;
      31    V (*fn) (V);
      32  } tests[] = {
      33  #undef TESTN
      34  #define TESTN(N) { N, test##N },
      35    TESTS
      36  };
      37  
      38  static void
      39  TEST (void)
      40  {
      41    V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL };
      42    V b = (V) { 0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL };
      43    int i;
      44    for (i = 0; i < ARRAY_SIZE (tests); i++)
      45      {
      46        V c = tests[i].fn (a);
      47        if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n)
      48  	abort ();
      49        c = tests[i].fn (b);
      50        if (c[0] != b[0] >> tests[i].n || c[1] != b[1] >> tests[i].n)
      51  	abort ();
      52      }
      53  }