1 /* PR target/84220 */
2 /* Test to ensure we generate invalid parameter errors rather than an ICE
3     when calling vec_xxpermdi() with invalid parameters.  */
4 /* { dg-do compile } */
5 /* { dg-require-effective-target powerpc_vsx_ok } */
6 /* { dg-options "-O2 -mvsx" } */
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 unsigned long long vullx = { 0, 1 };
20 vector unsigned long long vully = { 2, 3 };
21 vector unsigned long long vullz;
22 
23 vector float vfx = { 0.0, 1.0, 2.0, 3.0 };
24 vector float vfy = { 4.0, 5.0, 6.0, 7.0 };
25 vector float vfz;
26 
27 vector signed int vsix = { 0, 1, 2, 3 };
28 vector signed int vsiy = { 4, 5, 6, 7 };
29 vector signed int vsiz;
30 
31 vector unsigned int vuix = { 0, 1, 2, 3 };
32 vector unsigned int vuiy = { 4, 5, 6, 7 };
33 vector unsigned int vuiz;
34 
35 vector signed short vssx = { 0, 1, 2, 3, 4, 5, 6, 7 };
36 vector signed short vssy = { 8, 9, 10, 11, 12, 13, 14, 15 };
37 vector signed short vssz;
38 
39 vector unsigned short vusx = { 0, 1, 2, 3, 4, 5, 6, 7 };
40 vector unsigned short vusy = { 8, 9, 10, 11, 12, 13, 14, 15 };
41 vector unsigned short vusz;
42 
43 vector signed char vscx = { 0, 1, 2, 3, 4, 5, 6, 7,
44 			    8, 9, 10, 11, 12, 13, 14, 15 };
45 vector signed char vscy = { 16, 17, 18, 19, 20, 21, 22, 23,
46 			    24, 25, 26, 27, 28, 29, 30, 31 };
47 vector signed char vscz;
48 
49 vector unsigned char vucx = { 0, 1, 2, 3, 4, 5, 6, 7,
50 			    8, 9, 10, 11, 12, 13, 14, 15 };
51 vector unsigned char vucy = { 16, 17, 18, 19, 20, 21, 22, 23,
52 			    24, 25, 26, 27, 28, 29, 30, 31 };
53 vector unsigned char vucz;
54 
55 int
main()56 main ()
57 {
58   vdz = vec_xxpermdi (vdx, vdy, 0b01);
59   if (vdz[0] != 0.0 || vdz[1] != 3.0)
60     abort ();
61   vdz = vec_xxpermdi (vdx, vdy, vscx); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
62   vsllz = vec_xxpermdi (vsllx, vslly, 0b10);
63   vsllz = vec_xxpermdi (vsllx, vslly, vslly); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
64   vullz = vec_xxpermdi (vullx, vully, 0b10);
65   vullz = vec_xxpermdi (vullx, vully, vully); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
66   if (vsllz[0] != 1 || vsllz[1] != 2)
67     abort ();
68 
69   vfz = vec_xxpermdi (vfx, vfy, 0b01);
70   vfz = vec_xxpermdi (vfx, vfy, vfy); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
71   if (vfz[0] != 0.0 || vfz[1] != 1.0 || vfz[2] != 6.0 || vfz[3] != 7.0)
72     abort ();
73 
74   vsiz = vec_xxpermdi (vsix, vsiy, 0b10);
75   vsiz = vec_xxpermdi (vsix, vsiy, vsiy); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
76   vuiz = vec_xxpermdi (vuix, vuiy, 0b10);
77   vuiz = vec_xxpermdi (vuix, vuiy, vuiy); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
78   if (vsiz[0] != 2 || vsiz[1] != 3 || vsiz[2] != 4 || vsiz[3] != 5)
79     abort ();
80 
81   vssz = vec_xxpermdi (vssx, vssy, 0b00);
82   vssz = vec_xxpermdi (vssx, vssy, vssy); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
83   vusz = vec_xxpermdi (vusx, vusy, 0b00);
84   vusz = vec_xxpermdi (vusx, vusy, vusy); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
85   if (vssz[0] != 0 || vssz[1] != 1 || vssz[2] != 2 || vssz[3] != 3
86       || vssz[4] != 8 || vssz[5] != 9 || vssz[6] != 10 || vssz[7] != 11)
87     abort ();
88 
89   vscz = vec_xxpermdi (vscx, vscy, 0b11);
90   vscz = vec_xxpermdi (vscx, vscy, vscy);/* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
91   vucz = vec_xxpermdi (vucx, vucy, 0b11);
92   vucz = vec_xxpermdi (vucx, vucy, vucy);/* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
93   if (vscz[0] != 8 || vscz[1] != 9 || vscz[2] != 10 || vscz[3] != 11
94       || vscz[4] != 12 || vscz[5] != 13 || vscz[6] != 14 || vscz[7] != 15
95       || vscz[8] != 24 || vscz[9] != 25 || vscz[10] != 26 || vscz[11] != 27
96       || vscz[12] != 28 || vscz[13] != 29 || vscz[14] != 30 || vscz[15] != 31)
97     abort ();
98 
99   return 0;
100 }
101