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 -save-temps -O2" } */
13 extern void abort (void);
15 volatile vector
double vresult_d_undefined
;
18 main (int argc
, char *argv
[])
21 vector
int vsrc_a_int
;
22 vector
int vresult_int
;
23 vector
int expected_vresult_int
;
26 vector
unsigned int vsrc_a_uint
;
27 vector
unsigned int vresult_uint
;
28 vector
unsigned int expected_vresult_uint
;
29 unsigned int src_a_uint
= 7;
31 vector
float vresult_f
;
32 vector
float expected_vresult_f
;
33 vector
float vsrc_a_f
;
36 vector
double vsrc_a_d
;
37 vector
double vresult_d
;
38 vector
double expected_vresult_d
;
40 /* Vector splati word */
41 vresult_int
= (vector
signed int) { 1, 2, 3, 4 };
42 expected_vresult_int
= (vector
signed int) { -13, -13, -13, -13 };
44 vresult_int
= vec_splati ( -13 );
46 if (!vec_all_eq (vresult_int
, expected_vresult_int
)) {
48 printf("ERROR, vec_splati (src_a_int)\n");
49 for(i
= 0; i
< 4; i
++)
50 printf(" vresult_int[%d] = %d, expected_vresult_int[%d] = %d\n",
51 i
, vresult_int
[i
], i
, expected_vresult_int
[i
]);
57 vresult_f
= (vector
float) { 1.0, 2.0, 3.0, 4.0 };
58 expected_vresult_f
= (vector
float) { 23.0, 23.0, 23.0, 23.0 };
60 vresult_f
= vec_splati (23.0f
);
62 if (!vec_all_eq (vresult_f
, expected_vresult_f
)) {
64 printf("ERROR, vec_splati (src_a_f)\n");
65 for(i
= 0; i
< 4; i
++)
66 printf(" vresult_f[%d] = %f, expected_vresult_f[%d] = %f\n",
67 i
, vresult_f
[i
], i
, expected_vresult_f
[i
]);
73 /* Vector splati double */
74 vresult_d
= (vector
double) { 2.0, 3.0 };
75 expected_vresult_d
= (vector
double) { -31.0, -31.0 };
77 vresult_d
= vec_splatid (-31.0f
);
79 if (!vec_all_eq (vresult_d
, expected_vresult_d
)) {
81 printf("ERROR, vec_splati (-31.0f)\n");
82 for(i
= 0; i
< 2; i
++)
83 printf(" vresult_d[%i] = %f, expected_vresult_d[%i] = %f\n",
84 i
, vresult_d
[i
], i
, expected_vresult_d
[i
]);
90 /* This test will generate a "note" to the user that the argument is
91 subnormal. It is not an error, but results are not defined. Because this
92 is undefined, we cannot check that any value is correct. Just store it in
93 a volatile variable so the XXSPLTIDP instruction gets generated and the
94 warning message printed. */
95 vresult_d_undefined
= vec_splatid (6.6E-42f
);
97 /* Vector splat immediate */
98 vsrc_a_int
= (vector
int) { 2, 3, 4, 5 };
99 vresult_int
= (vector
int) { 1, 1, 1, 1 };
100 expected_vresult_int
= (vector
int) { 2, 20, 4, 20 };
102 vresult_int
= vec_splati_ins (vsrc_a_int
, 1, 20);
104 if (!vec_all_eq (vresult_int
, expected_vresult_int
)) {
106 printf("ERROR, vec_splati_ins (vsrc_a_int, 1, 20)\n");
107 for(i
= 0; i
< 4; i
++)
108 printf(" vresult_int[%i] = %d, expected_vresult_int[%i] = %d\n",
109 i
, vresult_int
[i
], i
, expected_vresult_int
[i
]);
115 vsrc_a_uint
= (vector
unsigned int) { 4, 5, 6, 7 };
116 vresult_uint
= (vector
unsigned int) { 1, 1, 1, 1 };
117 expected_vresult_uint
= (vector
unsigned int) { 4, 40, 6, 40 };
119 vresult_uint
= vec_splati_ins (vsrc_a_uint
, 1, 40);
121 if (!vec_all_eq (vresult_uint
, expected_vresult_uint
)) {
123 printf("ERROR, vec_splati_ins (vsrc_a_uint, 1, 40)\n");
124 for(i
= 0; i
< 4; i
++)
125 printf(" vresult_uint[%i] = %d, expected_vresult_uint[%i] = %d\n",
126 i
, vresult_uint
[i
], i
, expected_vresult_uint
[i
]);
132 vsrc_a_f
= (vector
float) { 2.0, 3.0, 4.0, 5.0 };
133 vresult_f
= (vector
float) { 1.0, 1.0, 1.0, 1.0 };
134 expected_vresult_f
= (vector
float) { 2.0, 20.1, 4.0, 20.1 };
136 vresult_f
= vec_splati_ins (vsrc_a_f
, 1, 20.1f
);
138 if (!vec_all_eq (vresult_f
, expected_vresult_f
)) {
140 printf("ERROR, vec_splati_ins (vsrc_a_f, 1, 20.1)\n");
141 for(i
= 0; i
< 4; i
++)
142 printf(" vresult_f[%i] = %f, expected_vresult_f[%i] = %f\n",
143 i
, vresult_f
[i
], i
, expected_vresult_f
[i
]);
152 /* { dg-final { scan-assembler-times {\mxxspltiw\M} 3 } } */
153 /* { dg-final { scan-assembler-times {\mxxspltidp\M} 3 } } */
154 /* { dg-final { scan-assembler-times {\mxxsplti32dx\M} 3 } } */