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. */
11 extern void abort (void);
13 #define CONST0 (3.1415926539)
14 #define CONST1 (3.1415926539 * 2)
15 #define CONST2 (3.1415926539 * 3)
16 #define CONST3 (3.1415926539 * 4)
19 /* Test that indices > length of vector are applied modulo the vector
22 /* Test for vector residing in register. */
23 vector
double e0(vector
double v
, double x
)
25 return vec_insert (x
, v
, 0);
28 vector
double e1(vector
double v
, double x
)
30 return vec_insert (x
, v
, 1);
33 vector
double e2(vector
double v
, double x
)
35 return vec_insert (x
, v
, 2);
38 vector
double e3(vector
double v
, double x
)
40 return vec_insert (x
, v
, 3);
43 /* Test for vector residing in memory. */
44 vector
double me0(vector
double *vp
, double x
)
46 return vec_insert (x
, *vp
, 0);
49 vector
double me1(vector
double *vp
, double x
)
51 return vec_insert (x
, *vp
, 1);
54 vector
double me2(vector
double *vp
, double x
)
56 return vec_insert (x
, *vp
, 2);
59 vector
double me3(vector
double *vp
, double x
)
61 return vec_insert (x
, *vp
, 3);
64 /* Test the same with variable indices. */
66 /* Test for variable selector and vector residing in register. */
67 __attribute__((noinline
))
68 vector
double ei(vector
double v
, int i
, double x
)
70 return vec_insert (x
, v
, i
);
73 /* Test for variable selector and vector residing in memory. */
74 __attribute__((noinline
))
75 vector
double mei(vector
double *vp
, int i
, double x
)
77 return vec_insert (x
, *vp
, i
);
80 int main (int argc
, char *argv
[]) {
102 dv
= me0 (&dv
, CONST2
);
103 if (dv
[0] != CONST2
)
106 dv
= me1 (&dv
, CONST3
);
107 if (dv
[1] != CONST3
)
110 dv
= me2 (&dv
, CONST1
);
111 if (dv
[0] != CONST1
)
114 dv
= me3 (&dv
, CONST0
);
115 if (dv
[1] != CONST0
)
118 dv
= ei (dv
, 0, CONST1
);
119 if (dv
[0] != CONST1
)
122 dv
= ei (dv
, 1, CONST0
);
123 if (dv
[1] != CONST0
)
126 dv
= ei (dv
, 2, CONST3
);
127 if (dv
[0] != CONST3
)
130 dv
= ei (dv
, 3, CONST2
);
131 if (dv
[1] != CONST2
)
134 dv
= mei (&dv
, 0, CONST1
);
135 if (dv
[0] != CONST1
)
138 dv
= mei (&dv
, 1, CONST0
);
139 if (dv
[1] != CONST0
)
142 dv
= mei (&dv
, 2, CONST2
);
143 if (dv
[0] != CONST2
)
146 dv
= mei (&dv
, 3, CONST3
);
147 if (dv
[1] != CONST3
)