1 /* { dg-do run } */
2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O3" } */
4 
5 #include <altivec.h>
6 void abort ();
7 
8 #define N 4096
9 int ca[N] __attribute__((aligned(16)));
10 int cb[N] __attribute__((aligned(16)));
11 int cc[N] __attribute__((aligned(16)));
12 int cd[N] __attribute__((aligned(16)));
13 int hey;
14 
foo()15 __attribute__((noinline)) void foo ()
16 {
17   int i;
18   vector int va, vb, vc, vd, tmp;
19   vector unsigned int threes = vec_splat_u32(3);
20   for (i = 0; i < N; i+=4) {
21     vb = vec_vsx_ld (0, &cb[i]);
22     vc = vec_vsx_ld (0, &cc[i]);
23     vd = vec_vsx_ld (0, &cd[i]);
24     tmp = vec_add (vb, vc);
25     tmp = vec_sub (tmp, vd);
26     tmp = vec_sra (tmp, threes);
27     hey = tmp[3];
28     vec_vsx_st (tmp, 0, &ca[i]);
29   }
30 }
31 
init()32 __attribute__((noinline)) void init ()
33 {
34   int i;
35   for (i = 0; i < N; ++i) {
36     cb[i] = 3 * i - 2048;
37     cc[i] = -5 * i + 93;
38     cd[i] = i + 14;
39   }
40 }
41 
main()42 int main ()
43 {
44   int i;
45   init ();
46   foo ();
47   for (i = 0; i < N; ++i)
48     if (ca[i] != (-3 * i - 1969) >> 3)
49       abort ();
50   if (hey != ca[N-1])
51     abort ();
52   return 0;
53 }
54