[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-20a.c
blob12350c3ed7a4b81194d5132314badde691540b26
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 extern void abort (void);
16 #define CONST0 (((unsigned __int128) 31415926539) << 60)
18 /* Test that indices > length of vector are applied modulo the vector
19 length. */
21 /* Test for vector residing in register. */
22 unsigned __int128 e0 (vector unsigned __int128 v)
24 return __builtin_vec_extract (v, 0);
27 unsigned __int128 e3 (vector unsigned __int128 v)
29 return __builtin_vec_extract (v, 3);
32 /* Test for vector residing in memory. */
33 unsigned __int128 me0 (vector unsigned __int128 *vp)
35 return __builtin_vec_extract (*vp, 0);
38 unsigned __int128 me3 (vector unsigned __int128 *vp)
40 return __builtin_vec_extract (*vp, 3);
43 /* Test the same with variable indices. */
45 #ifdef PR89424
46 /* Test for variable selector and vector residing in register. */
47 __attribute__((noinline))
48 unsigned __int128 ei (vector unsigned __int128 v, int i)
50 return __builtin_vec_extract (v, i);
53 /* Test for variable selector and vector residing in memory. */
54 unsigned __int128 mei (vector unsigned __int128 *vp, int i)
56 return __builtin_vec_extract (*vp, i);
58 #endif
60 int main (int argc, char *argv[]) {
61 vector unsigned __int128 dv = { CONST0 };
62 unsigned __int128 d;
64 d = e0 (dv);
65 if (d != CONST0)
66 abort ();
68 d = e3 (dv);
69 if (d != CONST0)
70 abort ();
72 d = me0 (&dv);
73 if (d != CONST0)
74 abort ();
76 d = me3 (&dv);
77 if (d != CONST0)
78 abort ();
80 #ifdef PR89424
81 d = ei (dv, 0);
82 if (d != CONST0)
83 abort ();
85 d = ei (dv, 1);
86 if (d != CONST0)
87 abort ();
89 d = ei (dv, 2);
90 if (d != CONST0)
91 abort ();
93 d = ei (dv, 3);
94 if (d != CONST0)
95 abort ();
97 d = mei (&dv, 0);
98 if (d != CONST0)
99 abort ();
101 d = mei (&dv, 1);
102 if (d != CONST0)
103 abort ();
105 d = mei (&dv, 2);
106 if (d != CONST0)
107 abort ();
109 d = mei (&dv, 3);
110 if (d != CONST0)
111 abort ();
112 #endif
114 return 0;