1  /* PR tree-optimization/96239 */
       2  /* { dg-do run { target { ilp32 || lp64 } } } */
       3  /* { dg-options "-O2 -fdump-tree-optimized" } */
       4  /* { dg-final { scan-tree-dump-times " r>> 8;" 1 "optimized" { target bswap } } } */
       5  /* { dg-final { scan-tree-dump-times " = __builtin_bswap64 " 1 "optimized" { target bswap } } } */
       6  /* { dg-final { scan-tree-dump-not " >> \(8\|16\|24\|32\|40\|48\|56\);" "optimized" { target bswap } } } */
       7  
       8  typedef unsigned char V __attribute__((vector_size (2)));
       9  typedef unsigned char W __attribute__((vector_size (8)));
      10  
      11  __attribute__((noipa)) void
      12  foo (unsigned short x, V *p)
      13  {
      14    *p = (V) { x >> 8, x };
      15  }
      16  
      17  __attribute__((noipa)) void
      18  bar (unsigned long long x, W *p)
      19  {
      20    *p = (W) { x >> 56, x >> 48, x >> 40, x >> 32, x >> 24, x >> 16, x >> 8, x };
      21  }
      22  
      23  __attribute__((noipa)) void
      24  baz (unsigned short x, V *p)
      25  {
      26    *p = (V) { x, x >> 8 };
      27  }
      28  
      29  __attribute__((noipa)) void
      30  qux (unsigned long long x, W *p)
      31  {
      32    *p = (W) { x, x >> 8, x >> 16, x >> 24, x >> 32, x >> 40, x >> 48, x >> 56 };
      33  }
      34  
      35  int
      36  main ()
      37  {
      38    V a, c, e, g;
      39    W b, d, f, h;
      40    foo (0xcafe, &a);
      41    bar (0xdeadbeefcafebabeULL, &b);
      42    baz (0xdead, &c);
      43    qux (0xfeedbac1beefdeadULL, &d);
      44    e = (V) { 0xca, 0xfe };
      45    f = (W) { 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe };
      46    g = (V) { 0xad, 0xde };
      47    h = (W) { 0xad, 0xde, 0xef, 0xbe, 0xc1, 0xba, 0xed, 0xfe };
      48    if (__builtin_memcmp (&a, &e, sizeof (V))
      49        || __builtin_memcmp (&b, &f, sizeof (W))
      50        || __builtin_memcmp (&c, &g, sizeof (V))
      51        || __builtin_memcmp (&d, &h, sizeof (W)))
      52      __builtin_abort ();
      53    return 0;
      54  }