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