[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vec-cmpne.h
bloba304de01d86bd077c00f1d08cb3b205fa409ea61
1 #include "altivec.h"
3 #define N 4096
5 void abort ();
7 #define PRAGMA(X) _Pragma (#X)
8 #define UNROLL0 PRAGMA (GCC unroll 0)
10 #define define_test_functions(VBTYPE, RTYPE, STYPE, NAME) \
12 RTYPE result_ne_##NAME[N] __attribute__((aligned(16))); \
13 RTYPE result_eq_##NAME[N] __attribute__((aligned(16))); \
14 STYPE operand1_##NAME[N] __attribute__((aligned(16))); \
15 STYPE operand2_##NAME[N] __attribute__((aligned(16))); \
16 RTYPE expected_##NAME[N] __attribute__((aligned(16))); \
18 __attribute__((noinline)) void vector_tests_##NAME () \
19 { \
20 vector STYPE v1_##NAME, v2_##NAME; \
21 vector bool VBTYPE tmp_##NAME; \
22 int i; \
23 UNROLL0 \
24 for (i = 0; i < N; i+=16/sizeof (STYPE)) \
25 { \
26 /* result_ne = operand1!=operand2. */ \
27 v1_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand1_##NAME[i]); \
28 v2_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand2_##NAME[i]); \
30 tmp_##NAME = vec_cmpeq (v1_##NAME, v2_##NAME); \
31 vec_vsx_st (tmp_##NAME, 0, &result_eq_##NAME[i]); \
33 tmp_##NAME = vec_cmpne (v1_##NAME, v2_##NAME); \
34 vec_vsx_st (tmp_##NAME, 0, &result_ne_##NAME[i]); \
35 } \
36 } \
38 #define define_init_verify_functions(VBTYPE, RTYPE, STYPE, NAME) \
39 __attribute__((noinline)) void init_##NAME () \
40 { \
41 int i; \
42 for (i = 0; i < N; ++i) \
43 { \
44 result_ne_##NAME[i] = 7; \
45 result_eq_##NAME[i] = 15; \
46 if (i%3 == 0) \
47 { \
48 /* op1 < op2. */ \
49 operand1_##NAME[i] = 1; \
50 operand2_##NAME[i] = 2; \
51 } \
52 else if (i%3 == 1) \
53 { \
54 /* op1 > op2. */ \
55 operand1_##NAME[i] = 2; \
56 operand2_##NAME[i] = 1; \
57 } \
58 else if (i%3 == 2) \
59 { \
60 /* op1 == op2. */ \
61 operand1_##NAME[i] = 3; \
62 operand2_##NAME[i] = 3; \
63 } \
64 /* For vector comparisons: "For each element of the result_ne, the \
65 value of each bit is 1 if the corresponding elements of ARG1 and \
66 ARG2 are equal." {or whatever the comparison is} "Otherwise, the \
67 value of each bit is 0." */ \
68 expected_##NAME[i] = -1 * (RTYPE)(operand1_##NAME[i] != operand2_##NAME[i]); \
69 } \
70 } \
72 __attribute__((noinline)) void verify_results_##NAME () \
73 { \
74 int i; \
75 for (i = 0; i < N; ++i) \
76 { \
77 if ( ((result_ne_##NAME[i] != expected_##NAME[i]) || \
78 (result_ne_##NAME[i] == result_eq_##NAME[i]))) \
79 abort (); \
80 } \
84 #define execute_test_functions(VBTYPE, RTYPE, STYPE, NAME) \
85 { \
86 init_##NAME (); \
87 vector_tests_##NAME (); \
88 verify_results_##NAME (); \