[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-20c.c
blobe56d500515ed1e854be392fd81af95366aa4df79
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 (((unsigned __int128) 31415926539) << 60)
14 #define CONST1 (((unsigned __int128) 31415926539) << 54)
15 #define CONST2 (((unsigned __int128) 31415926539) << 48)
16 #define CONST3 (((unsigned __int128) 31415926539) << 32)
18 /* Test that indices > length of vector are applied modulo the vector
19 length. */
21 /* Test for vector residing in register. */
22 vector unsigned __int128 e0 (vector unsigned __int128 v, unsigned __int128 x)
24 return vec_insert (x, v, 0);
27 vector unsigned __int128 e3 (vector unsigned __int128 v, unsigned __int128 x)
29 return vec_insert (x, v, 3);
32 /* Test for vector residing in memory. */
33 vector unsigned __int128
34 me0 (vector unsigned __int128 *vp, unsigned __int128 x)
36 return vec_insert (x, *vp, 0);
39 vector unsigned __int128
40 me3 (vector unsigned __int128 *vp, unsigned __int128 x)
42 return vec_insert (x, *vp, 3);
45 /* Test the same with variable indices. */
47 /* Test for variable selector and vector residing in register. */
48 __attribute__((noinline))
49 vector unsigned __int128
50 ei (vector unsigned __int128 v, int i, unsigned __int128 x)
52 return vec_insert (x, v, i);
55 /* Test for variable selector and vector residing in memory. */
56 __attribute__((noinline))
57 vector unsigned __int128
58 mei (vector unsigned __int128 *vp, int i, unsigned __int128 x)
60 return vec_insert (x, *vp, i);
63 int main (int argc, char *argv[]) {
64 vector unsigned __int128 dv = { CONST0 };
66 dv = e0 (dv, CONST3);
67 if (dv [0] != CONST3)
68 abort ();
70 dv = e3 (dv, CONST2);
71 if (dv [0] != CONST2)
72 abort ();
74 dv = me0 (&dv, CONST1);
75 if (dv [0] != CONST1)
76 abort ();
78 dv = me3 (&dv, CONST3);
79 if (dv [0] != CONST3)
80 abort ();
82 dv = ei (dv, 0, CONST0);
83 if (dv [0] != CONST0)
84 abort ();
86 dv = ei (dv, 1, CONST1);
87 if (dv [0] != CONST1)
88 abort ();
90 dv = ei (dv, 2, CONST2);
91 if (dv [0] != CONST2)
92 abort ();
94 dv = ei (dv, 3, CONST3);
95 if (dv [0] != CONST3)
96 abort ();
98 dv = mei (&dv, 0, CONST0);
99 if (dv [0] != CONST0)
100 abort ();
102 dv = mei (&dv, 1, CONST1);
103 if (dv [0] != CONST1)
104 abort ();
106 dv = mei (&dv, 2, CONST2);
107 if (dv [0] != CONST2)
108 abort ();
110 dv = mei (&dv, 3, CONST3);
111 if (dv [0] != CONST3)
112 abort ();
114 return 0;