1 /* { dg-do run } */
2 /* { dg-require-effective-target avx } */
3 /* { dg-options "-O -mavx" } */
4 
5 #include "avx-check.h"
6 
7 typedef char __attribute__ ((__vector_size__ (8))) v8qi;
8 typedef short __attribute__ ((__vector_size__ (8))) v4hi;
9 typedef int __attribute__ ((__vector_size__ (8))) v2si;
10 typedef long long __attribute__ ((__vector_size__ (8))) v1di;
11 typedef unsigned long long u64;
12 u64 k, c;
13 
14 v8qi g, h, p, q;
15 v4hi d, e, f, l, n, o;
16 v2si j;
17 
18 u64
foo(v4hi r)19 foo (v4hi r)
20 {
21   v8qi s;
22   f = (v4hi) j;
23   e = __builtin_ia32_psrlwi ((v4hi) k, c);
24   s = __builtin_ia32_pavgb (h, h);
25   n = __builtin_ia32_pabsw (f);
26   o = __builtin_ia32_psubusw (n, l);
27   p = __builtin_ia32_packsswb (r, o);
28   q = __builtin_ia32_pshufb (p, s);
29   g = __builtin_ia32_punpcklbw (q, (v8qi) r);
30   d = r;
31   return (u64) g + (u64) h + (u64) j;
32 }
33 
34 static void
avx_test(void)35 avx_test (void)
36 {
37   u64 x = foo ((v4hi) { 5 });
38   if (x != 0x0005000500050505)
39     __builtin_abort ();
40 }
41