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