[PATCH] RISC-V/libgcc: Fix incorrect .cfi_offset for saving ra in __riscv_save_[0...
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-14a.c
blob8eb8eb63fbebeea8a80ea110ac87c694512693a3
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/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 ((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
19 length. */
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 };
59 float d;
61 d = e0 (dv);
62 if (d != CONST0)
63 abort ();
65 d = e1 (dv);
66 if (d != CONST1)
67 abort ();
69 d = e7 (dv);
70 if (d != CONST3)
71 abort ();
73 d = e8 (dv);
74 if (d != CONST0)
75 abort ();
77 d = me0 (&dv);
78 if (d != CONST0)
79 abort ();
81 d = me1 (&dv);
82 if (d != CONST1)
83 abort ();
85 d = me13 (&dv);
86 if (d != CONST1)
87 abort ();
89 d = me15 (&dv);
90 if (d != CONST3)
91 abort ();
93 d = ei (dv, 0);
94 if (d != CONST0)
95 abort ();
97 d = ei (dv, 2);
98 if (d != CONST2)
99 abort ();
101 d = ei (dv, 11);
102 if (d != CONST3)
103 abort ();
105 d = ei (dv, 17);
106 if (d != CONST1)
107 abort ();
109 d = mei (&dv, 0);
110 if (d != CONST0)
111 abort ();
113 d = mei (&dv, 1);
114 if (d != CONST1)
115 abort ();
117 d = mei (&dv, 15);
118 if (d != CONST3)
119 abort ();
121 d = mei (&dv, 6);
122 if (d != CONST2)
123 abort ();
125 return 0;