2 /* { dg-require-effective-target p8vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power8 -O2" } */
22 vector
float vec_f_expected1
, vec_f_result1
, vec_f_error
;
23 vector
double vec_d_expected1
, vec_d_result1
, vec_d_error
;
25 /* vec_expte: float args, result */
26 f_arg1
= (vector
float){1.0, 2.0, 3.0, 4.0};
27 vec_f_expected1
= (vector
float){2.0, 4.0, 8.0, 16.0};
29 vec_f_result1
= vec_expte (f_arg1
);
31 for (i
= 0; i
< 4; i
++)
33 if (vec_f_expected1
[i
] != vec_f_result1
[i
])
35 printf("ERROR vec_expte (f) result[%d]=%f != expected[%d]=%f\n",
36 i
, vec_f_result1
[i
], i
, vec_f_expected1
[i
]);
42 /* vec_loge: float args, result */
43 f_arg1
= (vector
float){4.0, 8.0, 16.0, 64};
44 vec_f_expected1
= (vector
float){2.0, 3.0, 4.0, 6.0};
46 vec_f_result1
= vec_loge (f_arg1
);
48 for (i
= 0; i
< 4; i
++)
50 if (vec_f_expected1
[i
] != vec_f_result1
[i
])
52 printf("ERROR vec_loge (f) result[%d]=%f != expected[%d]=%f\n",
53 i
, vec_f_result1
[i
], i
, vec_f_expected1
[i
]);
59 /* vec_re: float args, result (calculate approximate reciprocal) */
60 f_arg1
= (vector
float){1.0, 5.0, 4.0, 8.0};
61 vec_f_expected1
= (vector
float){1.0, 0.2, 0.25, 0.125};
62 vec_f_error
= (vector
float){1.0, 0.2, 0.25, 0.125};
64 vec_f_result1
= vec_re (f_arg1
);
66 for (i
= 0; i
< 4; i
++)
68 vec_f_error
[i
] = fabs(vec_f_expected1
[i
] - vec_f_result1
[i
]);
70 if (vec_f_error
[i
] >= 0.0001)
72 printf("ERROR vec_re (f) result[%d]=%f != expected[%d]=%f\n",
73 i
, vec_f_result1
[i
], i
, vec_f_expected1
[i
]);
79 /* vec_re: double args, result (calculate approximate reciprocal) */
80 d_arg1
= (vector
double){1.0, 8.0};
81 vec_d_expected1
= (vector
double){1.0, 0.125};
82 vec_d_error
= (vector
double){1.0, 0.125};
84 vec_d_result1
= vec_re (d_arg1
);
86 for (i
= 0; i
< 2; i
++)
88 vec_d_error
[i
] = fabs(vec_d_expected1
[i
] - vec_d_result1
[i
]);
90 if (vec_d_error
[i
] >= 0.0001)
92 printf("ERROR vec_re (d) result[%d]=%f != expected[%d]=%f\n",
93 i
, vec_d_result1
[i
], i
, vec_d_expected1
[i
]);