2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec" } */
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. */
11 extern void abort (void);
13 #define CONST0 ((float) (3.1415926539))
14 #define CONST1 ((float) (3.1415926539 * 2))
15 #define CONST2 ((float) (3.1415926539 * 3))
16 #define CONST3 ((float) (3.1415926539 * 4))
18 /* Test that indices > length of vector are applied modulo the vector
21 /* Test for vector residing in register. */
22 float e0(vector
float v
){ return __builtin_vec_ext_v4sf (v
, 0); }
23 float e1(vector
float v
){ return __builtin_vec_ext_v4sf (v
, 1); }
24 float e7(vector
float v
){ return __builtin_vec_ext_v4sf (v
, 7); }
25 float e8(vector
float v
){ return __builtin_vec_ext_v4sf (v
, 8); }
27 /* Test for vector residing in memory. */
28 float me0(vector
float *vp
){ return __builtin_vec_ext_v4sf (*vp
, 0); }
29 float me1(vector
float *vp
){ return __builtin_vec_ext_v4sf (*vp
, 1); }
31 float me13(vector
float *vp
)
33 return __builtin_vec_ext_v4sf (*vp
, 13);
36 float me15(vector
float *vp
)
38 return __builtin_vec_ext_v4sf (*vp
, 15);
41 /* Test the same with variable indices. */
43 /* Test for variable selector and vector residing in register. */
44 __attribute__((noinline
))
45 float ei(vector
float v
, int i
)
47 return __builtin_vec_ext_v4sf (v
, i
);
50 /* Test for variable selector and vector residing in memory. */
51 float mei(vector
float *vp
, int i
)
53 return __builtin_vec_ext_v4sf (*vp
, i
);
57 int main (int argc
, char *argv
[]) {
58 vector
float dv
= { CONST0
, CONST1
, CONST2
, CONST3
};