1 /* { dg-do compile { target { powerpc64le-*-* } } } */
2 /* { dg-options "-mdejagnu-cpu=power8 -O3" } */
3 /* { dg-final { scan-assembler "lxvd2x" } } */
4 /* { dg-final { scan-assembler "stxvd2x" } } */
5 /* { dg-final { scan-assembler "stxsdx" } } */
6 /* { dg-final { scan-assembler-times "xxpermdi" 1 } } */
7
8 /* The only xxpermdi expected is for the vec_splats. */
9
10 #include <altivec.h>
11 void abort ();
12
13 #define N 4096
14 long long ca[N] __attribute__((aligned(16)));
15 long long cb[N] __attribute__((aligned(16)));
16 long long cc[N] __attribute__((aligned(16)));
17 long long cd[N] __attribute__((aligned(16)));
18 long long x;
19
foo()20 __attribute__((noinline)) void foo ()
21 {
22 int i;
23 vector long long va, vb, vc, vd, tmp;
24 volatile unsigned long long three = 3;
25 vector unsigned long long threes = vec_splats (three);
26 for (i = 0; i < N; i+=2) {
27 vb = vec_vsx_ld (0, (vector long long *)&cb[i]);
28 vc = vec_vsx_ld (0, (vector long long *)&cc[i]);
29 vd = vec_vsx_ld (0, (vector long long *)&cd[i]);
30 tmp = vec_add (vb, vc);
31 tmp = vec_sub (tmp, vd);
32 tmp = vec_sra (tmp, threes);
33 x = vec_extract (tmp, 0);
34 vec_vsx_st (tmp, 0, (vector long long *)&ca[i]);
35 }
36 }
37
main()38 int main ()
39 {
40 foo ();
41 return 0;
42 }
43