[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-13a.c
blob7dc6bd994e476bd694ab9838990a1fec31d11e24
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 /* Define this after PR89424 is addressed. */
12 #define PR89424
14 /* Define this after PR89626 is addressed. */
15 #undef PR89626
17 #ifdef PR89626
18 #define SIGNED
19 #else
20 #define SIGNED signed
21 #endif
23 extern void abort (void);
25 #define CONST0 (((SIGNED __int128) 31415926539) << 60)
27 /* Test that indices > length of vector are applied modulo the vector
28 length. */
30 /* Test for vector residing in register. */
31 SIGNED __int128 e0 (vector SIGNED __int128 v)
33 return __builtin_vec_ext_v1ti (v, 0);
36 SIGNED __int128 e3 (vector SIGNED __int128 v)
38 return __builtin_vec_ext_v1ti (v, 3);
41 /* Test for vector residing in memory. */
42 SIGNED __int128 me0 (vector SIGNED __int128 *vp)
44 return __builtin_vec_ext_v1ti (*vp, 0);
47 SIGNED __int128 me3 (vector SIGNED __int128 *vp)
49 return __builtin_vec_ext_v1ti (*vp, 3);
52 /* Test the same with variable indices. */
54 #ifdef PR89424
55 /* Test for variable selector and vector residing in register. */
56 __attribute__((noinline))
57 SIGNED __int128 ei (vector SIGNED __int128 v, int i)
59 return __builtin_vec_ext_v1ti (v, i);
62 /* Test for variable selector and vector residing in memory. */
63 SIGNED __int128 mei (vector SIGNED __int128 *vp, int i)
65 return __builtin_vec_ext_v1ti (*vp, i);
67 #endif
69 int main (int argc, char *argv[]) {
70 vector SIGNED __int128 dv = { CONST0 };
71 SIGNED __int128 d;
73 d = e0 (dv);
74 if (d != CONST0)
75 abort ();
77 d = e3 (dv);
78 if (d != CONST0)
79 abort ();
81 d = me0 (&dv);
82 if (d != CONST0)
83 abort ();
85 d = me3 (&dv);
86 if (d != CONST0)
87 abort ();
89 #ifdef PR89424
90 d = ei (dv, 0);
91 if (d != CONST0)
92 abort ();
94 d = ei (dv, 1);
95 if (d != CONST0)
96 abort ();
98 d = ei (dv, 2);
99 if (d != CONST0)
100 abort ();
102 d = ei (dv, 3);
103 if (d != CONST0)
104 abort ();
106 d = mei (&dv, 0);
107 if (d != CONST0)
108 abort ();
110 d = mei (&dv, 1);
111 if (d != CONST0)
112 abort ();
114 d = mei (&dv, 2);
115 if (d != CONST0)
116 abort ();
118 d = mei (&dv, 3);
119 if (d != CONST0)
120 abort ();
121 #endif
123 return 0;