[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-18d.c
blob8c643aaafd316ed09127d26f815e10ca5f4cd9fc
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/vmx
6 instructions. Unsigned 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 unsigned int s3 (vector unsigned int v, unsigned int x)
24 return vec_insert (x, v, 3);
27 vector unsigned int s1 (vector unsigned int v, unsigned int x)
29 return vec_insert (x, v, 1);
32 vector unsigned int s21 (vector unsigned int v, unsigned int x)
34 return vec_insert (x, v, 21);
37 vector unsigned int s30 (vector unsigned int v, unsigned int x)
39 return vec_insert (x, v, 30);
42 /* Test for vector residing in memory. */
43 vector unsigned int ms3 (vector unsigned int *vp, unsigned int x)
45 return vec_insert (x, *vp, 3);
48 vector unsigned int ms1(vector unsigned int *vp, unsigned int x)
50 return vec_insert (x, *vp, 1);
53 vector unsigned int ms21(vector unsigned int *vp, unsigned int x)
55 return vec_insert (x, *vp, 21);
58 vector unsigned int ms30(vector unsigned int *vp, unsigned 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 unsigned int ci (vector unsigned int v, int i, unsigned int x)
69 return vec_insert (x, v, i);
72 /* Test for variable selector and vector residing in memory. */
73 __attribute__((noinline))
74 vector unsigned int mci(vector unsigned int *vp, int i, unsigned int x)
76 return vec_insert (x, *vp, i);
80 int main (int argc, unsigned char *argv[]) {
81 vector unsigned int sv = { CONST0, CONST1, CONST2, CONST3 };
83 sv = s3 (sv, CONST2);
84 if (sv [3] != CONST2)
85 abort ();
87 sv = s1 (sv, CONST2);
88 if (sv [1] != CONST2)
89 abort ();
91 sv = s21 (sv, CONST3);
92 if (sv [1] != CONST3)
93 abort ();
95 sv = s30 (sv, CONST1);
96 if (sv [2] != CONST1)
97 abort ();
99 sv = ms3 (&sv, CONST0);
100 if (sv [3] != CONST0)
101 abort ();
103 sv = ms1 (&sv, CONST0);
104 if (sv [1] != CONST0)
105 abort ();
107 sv = ms21 (&sv, CONST1);
108 if (sv [1] != CONST1)
109 abort ();
111 sv = ms30 (&sv, CONST0);
112 if (sv [2] != CONST0)
113 abort ();
115 sv = ci (sv, 5, CONST3);
116 if (sv [1] != CONST3)
117 abort ();
119 sv = ci (sv, 2, CONST0);
120 if (sv [2] != CONST0)
121 abort ();
123 sv = ci (sv, 15, CONST1);
124 if (sv [3] != CONST1)
125 abort ();
127 sv = ci (sv, 28, CONST3);
128 if (sv [0] != CONST3)
129 abort ();
131 sv = mci (&sv, 5, CONST0);
132 if (sv [1] != CONST0)
133 abort ();
135 sv = mci (&sv, 12, CONST2);
136 if (sv [0] != CONST2)
137 abort ();
139 sv = mci (&sv, 25, CONST3);
140 if (sv [1] != CONST3)
141 abort ();
143 sv = mci (&sv, 16, CONST1);
144 if (sv [0] != CONST1)
145 abort ();
147 return 0;