[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-11c.c
blob8e514aa2b1fccd8b8d13d03c1c8c6c772d0f338e
1 /* { dg-do run } */
2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec" } */
5 /* This test should run the same on any target that supports altivec/vmx
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)
18 /* Test that indices > length of vector are applied modulo the vector
19 length. */
21 /* Test for vector residing in register. */
22 vector int s3 (vector int v, int x)
24 return vec_insert (x, v, 3);
27 vector int s1 (vector int v, int x)
29 return vec_insert (x, v, 1);
32 vector int s21 (vector int v, int x)
34 return vec_insert (x, v, 21);
37 vector int s30 (vector int v, int x)
39 return vec_insert (x, v, 30);
42 /* Test for vector residing in memory. */
43 vector int ms3 (vector int *vp, int x)
45 return vec_insert (x, *vp, 3);
48 vector int ms1 (vector int *vp, int x)
50 return vec_insert (x, *vp, 1);
53 vector int ms21 (vector int *vp, int x)
55 return vec_insert (x, *vp, 21);
58 vector int ms30 (vector int *vp, int x)
60 return vec_insert (x, *vp, 30);
63 /* Test the same with variable indices. */
65 /* Test for variable selector and vector residing in register. */
66 __attribute__((noinline))
67 vector int ci (vector int v, int i, int x)
69 return vec_insert (x, v, i);
72 /* Test for variable selector and vector residing in memory. */
73 __attribute__((noinline))
74 vector int mci(vector int *vp, int i, int x)
76 return vec_insert (x, *vp, i);
80 int main (int argc, int *argv[]) {
81 vector int sv = { CONST0, CONST1, CONST2, CONST3 };
82 int s;
84 sv = s3 (sv, CONST1);
85 if (sv [3] != CONST1)
86 abort ();
88 sv = s1 (sv, CONST3);
89 if (sv [1] != CONST3)
90 abort ();
92 sv = s21 (sv, CONST0);
93 if (sv [1] != CONST0)
94 abort ();
96 sv = s30 (sv, CONST1);
97 if (sv [2] != CONST1)
98 abort ();
100 sv = ms3 (&sv, CONST2);
101 if (sv [3] != CONST2)
102 abort ();
104 sv = ms1 (&sv, CONST0);
105 if (sv [1] != CONST0)
106 abort ();
108 sv = ms21 (&sv, CONST3);
109 if (sv [1] != CONST3)
110 abort ();
112 sv = ms30 (&sv, CONST0);
113 if (sv [2] != CONST0)
114 abort ();
116 sv = ci (sv, 5, CONST0);
117 if (sv [1] != CONST0)
118 abort ();
120 sv = ci (sv, 2, CONST3);
121 if (sv [2] != CONST3)
122 abort ();
124 sv = ci (sv, 15, CONST1);
125 if (sv [3] != CONST1)
126 abort ();
128 sv = ci (sv, 28, CONST3);
129 if (sv [0] != CONST3)
130 abort ();
132 sv = mci (&sv, 5, CONST2);
133 if (sv [1] != CONST2)
134 abort ();
136 sv = mci (&sv, 12, CONST1);
137 if (sv [0] != CONST1)
138 abort ();
140 sv = mci (&sv, 25, CONST2);
141 if (sv [1] != CONST2)
142 abort ();
144 sv = mci (&sv, 16, CONST3);
145 if (sv [0] != CONST3)
146 abort ();
148 return 0;