1 /* { dg-do run { target { power10_hw } } } */
2 /* { dg-do link { target { ! power10_hw } } } */
3 /* { dg-require-effective-target power10_ok } */
4 /* { dg-options "-mdejagnu-cpu=power10" } */
13 extern void abort (void);
16 main (int argc
, char *argv
[])
19 vector
int vsrc_a_int
;
20 vector
int vresult_int
;
21 vector
int expected_vresult_int
;
24 vector
unsigned int vsrc_a_uint
;
25 vector
unsigned int vresult_uint
;
26 vector
unsigned int expected_vresult_uint
;
27 unsigned int src_a_uint
= 7;
29 vector
float vresult_f
;
30 vector
float expected_vresult_f
;
31 vector
float vsrc_a_f
;
34 vector
double vsrc_a_d
;
35 vector
double vresult_d
;
36 vector
double expected_vresult_d
;
38 /* Vector splati word */
39 vresult_int
= (vector
signed int) { 1, 2, 3, 4 };
40 expected_vresult_int
= (vector
signed int) { -13, -13, -13, -13 };
42 vresult_int
= vec_splati ( -13 );
44 if (!vec_all_eq (vresult_int
, expected_vresult_int
)) {
46 printf("ERROR, vec_splati (src_a_int)\n");
47 for(i
= 0; i
< 4; i
++)
48 printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n",
49 i
, vresult_int
[i
], i
, expected_vresult_int
[i
]);
55 vresult_f
= (vector
float) { 1.0, 2.0, 3.0, 4.0 };
56 expected_vresult_f
= (vector
float) { 23.0, 23.0, 23.0, 23.0 };
58 vresult_f
= vec_splati (23.0f
);
60 if (!vec_all_eq (vresult_f
, expected_vresult_f
)) {
62 printf("ERROR, vec_splati (src_a_f)\n");
63 for(i
= 0; i
< 4; i
++)
64 printf(" vresult_f[%d] = %f, expected_vresult_f[%d] = %f\n",
65 i
, vresult_f
[i
], i
, expected_vresult_f
[i
]);
71 /* Vector splati double */
72 vresult_d
= (vector
double) { 2.0, 3.0 };
73 expected_vresult_d
= (vector
double) { -31.0, -31.0 };
75 vresult_d
= vec_splatid (-31.0f
);
77 if (!vec_all_eq (vresult_d
, expected_vresult_d
)) {
79 printf("ERROR, vec_splati (-31.0f)\n");
80 for(i
= 0; i
< 2; i
++)
81 printf(" vresult_d[%i] = %f, expected_vresult_d[%i] = %f\n",
82 i
, vresult_d
[i
], i
, expected_vresult_d
[i
]);
88 /* This test will generate a "note" to the user that the argument
89 is subnormal. It is not an error, but results are not defined. */
90 vresult_d
= (vector
double) { 2.0, 3.0 };
91 expected_vresult_d
= (vector
double) { 6.6E-42f
, 6.6E-42f
};
93 vresult_d
= vec_splatid (6.6E-42f
);
95 /* Although the instruction says the results are not defined, it does seem
96 to work, at least on Mambo. But no guarentees! */
97 if (!vec_all_eq (vresult_d
, expected_vresult_d
)) {
99 printf("ERROR, vec_splati (6.6E-42f)\n");
100 for(i
= 0; i
< 2; i
++)
101 printf(" vresult_d[%i] = %e, expected_vresult_d[%i] = %e\n",
102 i
, vresult_d
[i
], i
, expected_vresult_d
[i
]);
108 /* Vector splat immediate */
109 vsrc_a_int
= (vector
int) { 2, 3, 4, 5 };
110 vresult_int
= (vector
int) { 1, 1, 1, 1 };
111 expected_vresult_int
= (vector
int) { 2, 20, 4, 20 };
113 vresult_int
= vec_splati_ins (vsrc_a_int
, 1, 20);
115 if (!vec_all_eq (vresult_int
, expected_vresult_int
)) {
117 printf("ERROR, vec_splati_ins (vsrc_a_int, 1, 20)\n");
118 for(i
= 0; i
< 4; i
++)
119 printf(" vresult_int[%i] = %d, expected_vresult_int[%i] = %d\n",
120 i
, vresult_int
[i
], i
, expected_vresult_int
[i
]);
126 vsrc_a_uint
= (vector
unsigned int) { 4, 5, 6, 7 };
127 vresult_uint
= (vector
unsigned int) { 1, 1, 1, 1 };
128 expected_vresult_uint
= (vector
unsigned int) { 4, 40, 6, 40 };
130 vresult_uint
= vec_splati_ins (vsrc_a_uint
, 1, 40);
132 if (!vec_all_eq (vresult_uint
, expected_vresult_uint
)) {
134 printf("ERROR, vec_splati_ins (vsrc_a_uint, 1, 40)\n");
135 for(i
= 0; i
< 4; i
++)
136 printf(" vresult_uint[%i] = %d, expected_vresult_uint[%i] = %d\n",
137 i
, vresult_uint
[i
], i
, expected_vresult_uint
[i
]);
143 vsrc_a_f
= (vector
float) { 2.0, 3.0, 4.0, 5.0 };
144 vresult_f
= (vector
float) { 1.0, 1.0, 1.0, 1.0 };
145 expected_vresult_f
= (vector
float) { 2.0, 20.1, 4.0, 20.1 };
147 vresult_f
= vec_splati_ins (vsrc_a_f
, 1, 20.1f
);
149 if (!vec_all_eq (vresult_f
, expected_vresult_f
)) {
151 printf("ERROR, vec_splati_ins (vsrc_a_f, 1, 20.1)\n");
152 for(i
= 0; i
< 4; i
++)
153 printf(" vresult_f[%i] = %f, expected_vresult_f[%i] = %f\n",
154 i
, vresult_f
[i
], i
, expected_vresult_f
[i
]);
163 /* { dg-final { scan-assembler-times {\mxxspltiw\M} 2 } } */
164 /* { dg-final { scan-assembler-times {\mxxspltidp\M} 2 } } */
165 /* { dg-final { scan-assembler-times {\mxxsplti32dx\M} 3 } } */