testsuite: enable and fix swaps-p8 testcases
[gcc.git] / gcc / testsuite / gcc.target / powerpc / swaps-p8-27.c
1 /* { dg-do compile } */
2 /* { dg-require-effective-target powerpc_p8vector_ok } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O3 " } */
4 /* { dg-final { scan-assembler-times "lxvd2x" 2 } } */
5 /* { dg-final { scan-assembler-times "stxvd2x" 1 } } */
6 /* { dg-final { scan-assembler-times "xxpermdi" 3 } } */
7
8 /* Verify that swap optimization works correctly for a VSX direct splat.
9 The three xxpermdi's that are generated correspond to two splats
10 and the __builtin_vsx_xxpermdi. */
11
12 int printf (const char *__restrict __format, ...);
13 typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
14
15 double s1[] = {2134.3343, 6678.346};
16 double s2[] = {41124.234, 6678.346};
17 long long dd[] = {1, 2}, d[2];
18 union{long long l[2]; double d[2];} e;
19
20 void
21 foo ()
22 {
23 __m128d source1, source2, dest;
24 __m128d a, b, c;
25
26 e.d[1] = s1[1];
27 e.l[0] = !__builtin_isunordered(s1[0], s2[0])
28 && s1[0] == s2[0] ? -1 : 0;
29 source1 = __builtin_vec_vsx_ld (0, s1);
30 source2 = __builtin_vec_vsx_ld (0, s2);
31 a = __builtin_vec_splat (source1, 0);
32 b = __builtin_vec_splat (source2, 0);
33 c = (__m128d)__builtin_vec_cmpeq (a, b);
34 dest = __builtin_vsx_xxpermdi (source1, c, 1);
35 *(__m128d *)d = dest;
36 }