testsuite: enable and fix swaps-p8 testcases
[gcc.git] / gcc / testsuite / gcc.target / powerpc / swaps-p8-20.c
1 /* { dg-do run } */
2 /* { dg-require-effective-target powerpc_altivec_ok } */
3 /* { dg-options "-O2 -mdejagnu-cpu=power8 -maltivec" } */
4
5 /* The expansion for vector character multiply introduces a vperm operation.
6 This tests that the swap optimization to remove swaps by changing the
7 vperm mask results in correct code. */
8
9 #include <altivec.h>
10
11 void abort ();
12
13 vector unsigned char r;
14 vector unsigned char v =
15 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
16 vector unsigned char i =
17 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
18 vector unsigned char e =
19 {0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240};
20
21 int main ()
22 {
23 int j;
24 r = v * i;
25 if (!vec_all_eq (r, e))
26 abort ();
27 return 0;
28 }