[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-15a.c
blobb8bff5c3f56fc704e53dddbb65851277630b5ee1
1 /* { dg-do run { target int128 } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-mvsx" } */
5 /* This test should run the same on any target that supports vsx
6 instructions. Intentionally not specifying cpu in order to test
7 all code generation paths. */
9 #include <altivec.h>
11 extern void abort (void);
13 #define CONST0 (3.1415926539)
14 #define CONST1 (3.1415926539 * 2)
17 /* Test that indices > length of vector are applied modulo the vector
18 length. */
20 /* Test for vector residing in register. */
21 double e0(vector double v){ return __builtin_vec_ext_v2df (v, 0); }
22 double e1(vector double v){ return __builtin_vec_ext_v2df (v, 1); }
23 double e2(vector double v){ return __builtin_vec_ext_v2df (v, 2); }
24 double e3(vector double v){ return __builtin_vec_ext_v2df (v, 3); }
26 /* Test for vector residing in memory. */
27 double me0(vector double *vp){ return __builtin_vec_ext_v2df (*vp, 0); }
28 double me1(vector double *vp){ return __builtin_vec_ext_v2df (*vp, 1); }
29 double me2(vector double *vp){ return __builtin_vec_ext_v2df (*vp, 2); }
30 double me3(vector double *vp){ return __builtin_vec_ext_v2df (*vp, 3); }
32 /* Test the same with variable indices. */
34 /* Test for variable selector and vector residing in register. */
35 __attribute__((noinline))
36 double ei(vector double v, int i){ return __builtin_vec_ext_v2df (v, i); }
38 /* Test for variable selector and vector residing in memory. */
39 double mei(vector double *vp, int i){ return __builtin_vec_ext_v2df (*vp, i); }
42 int main (int argc, char *argv[]) {
43 vector double dv;
44 double d;
45 dv[0] = CONST0;
46 dv[1] = CONST1;
48 d = e0 (dv);
49 if (d != CONST0)
50 abort ();
52 d = e1 (dv);
53 if (d != CONST1)
54 abort ();
56 d = e2 (dv);
57 if (d != CONST0)
58 abort ();
60 d = e3 (dv);
61 if (d != CONST1)
62 abort ();
64 d = me0 (&dv);
65 if (d != CONST0)
66 abort ();
68 d = me1 (&dv);
69 if (d != CONST1)
70 abort ();
72 d = me2 (&dv);
73 if (d != CONST0)
74 abort ();
76 d = me3 (&dv);
77 if (d != CONST1)
78 abort ();
80 d = ei (dv, 0);
81 if (d != CONST0)
82 abort ();
84 d = ei (dv, 1);
85 if (d != CONST1)
86 abort ();
88 d = ei (dv, 2);
89 if (d != CONST0)
90 abort ();
92 d = ei (dv, 3);
93 if (d != CONST1)
94 abort ();
96 d = mei (&dv, 0);
97 if (d != CONST0)
98 abort ();
100 d = mei (&dv, 1);
101 if (d != CONST1)
102 abort ();
104 d = mei (&dv, 2);
105 if (d != CONST0)
106 abort ();
108 d = mei (&dv, 3);
109 if (d != CONST1)
110 abort ();
112 return 0;