[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-9b.c
blobff081b354b2f0a53bac7e70a9f52a3786f309c0d
1 /* { dg-do run } */
2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec -O3" } */
5 /* This test should run the same on any target that supports altivec/dfp
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 (0)
14 #define CONST1 (1)
15 #define CONST2 (2)
16 #define CONST3 (3)
17 #define CONST4 (4)
18 #define CONST5 (5)
19 #define CONST6 (6)
20 #define CONST7 (7)
21 #define CONST8 (8)
22 #define CONST9 (9)
23 #define CONSTA (10)
24 #define CONSTB (11)
25 #define CONSTC (12)
26 #define CONSTD (13)
27 #define CONSTE (14)
28 #define CONSTF (15)
31 /* Test that indices > length of vector are applied modulo the vector
32 length. */
34 /* Test for vector residing in register. */
35 signed char c0 (vector signed char v)
37 return __builtin_vec_ext_v16qi (v, 0);
40 signed char c9 (vector signed char v)
42 return __builtin_vec_ext_v16qi (v, 9);
45 signed char c21 (vector signed char v)
47 return __builtin_vec_ext_v16qi (v, 21);
50 signed char c30 (vector signed char v)
52 return __builtin_vec_ext_v16qi (v, 30);
55 /* Test for vector residing in memory. */
56 signed char mc0 (vector signed char *vp)
58 return __builtin_vec_ext_v16qi (*vp, 0);
61 signed char mc9 (vector signed char *vp)
63 return __builtin_vec_ext_v16qi (*vp, 9);
66 signed char mc21 (vector signed char *vp)
68 return __builtin_vec_ext_v16qi (*vp, 21);
71 signed char mc30 (vector signed char *vp)
73 return __builtin_vec_ext_v16qi (*vp, 30);
76 /* Test the same with variable indices. */
78 /* Test for variable selector and vector residing in register. */
79 __attribute__((noinline))
80 signed char ci (vector signed char v, int i)
82 return __builtin_vec_ext_v16qi (v, i);
85 /* Test for variable selector and vector residing in memory. */
86 __attribute__((noinline))
87 signed char mci(vector signed char *vp, int i) {
88 return __builtin_vec_ext_v16qi (*vp, i);
92 int main (int argc, char *argv[]) {
93 vector signed char cv = { CONST0, CONST1, CONST2, CONST3,
94 CONST4, CONST5, CONST6, CONST7,
95 CONST8, CONST9, CONSTA, CONSTB,
96 CONSTC, CONSTD, CONSTE, CONSTF };
97 signed char c;
99 c = c0 (cv);
100 if (c != CONST0)
101 abort ();
103 c = c9 (cv);
104 if (c != CONST9)
105 abort ();
107 c = c21 (cv);
108 if (c != CONST5)
109 abort ();
111 c = c30 (cv);
112 if (c != CONSTE)
113 abort ();
115 c = mc0 (&cv);
116 if (c != CONST0)
117 abort ();
119 c = mc9 (&cv);
120 if (c != CONST9)
121 abort ();
123 c = mc21 (&cv);
124 if (c != CONST5)
125 abort ();
127 c = mc30 (&cv);
128 if (c != CONSTE)
129 abort ();
131 c = ci (cv, 8);
132 if (c != CONST8)
133 abort ();
135 c = ci (cv, 13);
136 if (c != CONSTD)
137 abort ();
139 c = ci (cv, 23);
140 if (c != CONST7)
141 abort ();
143 c = ci (cv, 31);
144 if (c != CONSTF)
145 abort ();
147 c = mci (&cv, 5);
148 if (c != CONST5)
149 abort ();
151 c = mci (&cv, 12);
152 if (c != CONSTC)
153 abort ();
155 c = mci (&cv, 25);
156 if (c != CONST9)
157 abort ();
159 c = mci (&cv, 16);
160 if (c != CONST0)
161 abort ();
163 return 0;