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