[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-19b.c
blobc39923e319b14c1f6da559ae62aae3e1a7d366b1
1 /* { dg-do run { target int128 } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-mvsx -O3" } */
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 (31415926539LL)
14 #define CONST1 (2 * 31415926539LL)
16 /* Test that indices > length of vector are applied modulo the vector
17 length. */
19 /* Test for vector residing in register. */
20 unsigned long long int e0 (vector unsigned long long int v)
22 return __builtin_vec_extract (v, 0);
25 unsigned long long int e3 (vector unsigned long long int v)
27 return __builtin_vec_extract (v, 3);
30 /* Test for vector residing in memory. */
31 unsigned long long int me0 (vector unsigned long long int *vp)
33 return __builtin_vec_extract (*vp, 0);
36 unsigned long long int me3 (vector unsigned long long int *vp)
38 return __builtin_vec_extract (*vp, 3);
41 /* Test the same with variable indices. */
43 /* Test for variable selector and vector residing in register. */
44 __attribute__((noinline))
45 unsigned long long int ei (vector unsigned long long int v, int i)
47 return __builtin_vec_extract (v, i);
50 /* Test for variable selector and vector residing in memory. */
51 unsigned long long int mei (vector unsigned long long int *vp, int i)
53 return __builtin_vec_extract (*vp, i);
56 int main (int argc, char *argv[]) {
57 vector unsigned long long int dv = { CONST0, CONST1 };
58 unsigned long long int d;
60 d = e0 (dv);
61 if (d != CONST0)
62 abort ();
64 d = e3 (dv);
65 if (d != CONST1)
66 abort ();
68 d = me0 (&dv);
69 if (d != CONST0)
70 abort ();
72 d = me3 (&dv);
73 if (d != CONST1)
74 abort ();
76 d = ei (dv, 0);
77 if (d != CONST0)
78 abort ();
80 d = ei (dv, 1);
81 if (d != CONST1)
82 abort ();
84 d = ei (dv, 2);
85 if (d != CONST0)
86 abort ();
88 d = ei (dv, 3);
89 if (d != CONST1)
90 abort ();
92 d = mei (&dv, 0);
93 if (d != CONST0)
94 abort ();
96 d = mei (&dv, 1);
97 if (d != CONST1)
98 abort ();
100 d = mei (&dv, 2);
101 if (d != CONST0)
102 abort ();
104 d = mei (&dv, 3);
105 if (d != CONST1)
106 abort ();
108 return 0;