1 /* { dg-do run } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O2 -mvsx" } */
4 
5 /* Added for PR79261 to test that vec_xxpermdi works correctly for
6    both BE and LE targets.  */
7 
8 #include <altivec.h>
9 void abort (void);
10 
11 vector double vdx = { 0.0, 1.0 };
12 vector double vdy = { 2.0, 3.0 };
13 vector double vdz;
14 
15 vector signed long long vsllx = { 0, 1 };
16 vector signed long long vslly = { 2, 3 };
17 vector signed long long vsllz;
18 
19 vector float vfx = { 0.0, 1.0, 2.0, 3.0 };
20 vector float vfy = { 4.0, 5.0, 6.0, 7.0 };
21 vector float vfz;
22 
23 vector signed int vsix = { 0, 1, 2, 3 };
24 vector signed int vsiy = { 4, 5, 6, 7 };
25 vector signed int vsiz;
26 
27 vector signed short vssx = { 0, 1, 2, 3, 4, 5, 6, 7 };
28 vector signed short vssy = { 8, 9, 10, 11, 12, 13, 14, 15 };
29 vector signed short vssz;
30 
31 vector signed char vscx = { 0, 1, 2, 3, 4, 5, 6, 7,
32 			    8, 9, 10, 11, 12, 13, 14, 15 };
33 vector signed char vscy = { 16, 17, 18, 19, 20, 21, 22, 23,
34 			    24, 25, 26, 27, 28, 29, 30, 31 };
35 vector signed char vscz;
36 
37 int
main()38 main ()
39 {
40   vdz = vec_xxpermdi (vdx, vdy, 0b01);
41   if (vdz[0] != 0.0 || vdz[1] != 3.0)
42     abort ();
43 
44   vsllz = vec_xxpermdi (vsllx, vslly, 0b10);
45   if (vsllz[0] != 1 || vsllz[1] != 2)
46     abort ();
47 
48   vfz = vec_xxpermdi (vfx, vfy, 0b01);
49   if (vfz[0] != 0.0 || vfz[1] != 1.0 || vfz[2] != 6.0 || vfz[3] != 7.0)
50     abort ();
51 
52   vsiz = vec_xxpermdi (vsix, vsiy, 0b10);
53   if (vsiz[0] != 2 || vsiz[1] != 3 || vsiz[2] != 4 || vsiz[3] != 5)
54     abort ();
55 
56   vssz = vec_xxpermdi (vssx, vssy, 0b00);
57   if (vssz[0] != 0 || vssz[1] != 1 || vssz[2] != 2 || vssz[3] != 3
58       || vssz[4] != 8 || vssz[5] != 9 || vssz[6] != 10 || vssz[7] != 11)
59     abort ();
60 
61   vscz = vec_xxpermdi (vscx, vscy, 0b11);
62   if (vscz[0] != 8 || vscz[1] != 9 || vscz[2] != 10 || vscz[3] != 11
63       || vscz[4] != 12 || vscz[5] != 13 || vscz[6] != 14 || vscz[7] != 15
64       || vscz[8] != 24 || vscz[9] != 25 || vscz[10] != 26 || vscz[11] != 27
65       || vscz[12] != 28 || vscz[13] != 29 || vscz[14] != 30 || vscz[15] != 31)
66     abort ();
67 
68   return 0;
69 }
70