1 /* { dg-do run { target { powerpc64*-*-* } } } */
2 /* { dg-require-effective-target powerpc_vsx_ok } */
3 /* { dg-options "-mvsx -O3" } */
5 /* Test that the vec_cmpne builtin works as expected. */
13 #define define_test_functions(VBTYPE, RTYPE, STYPE, NAME) \
15 RTYPE result_ne_##NAME[N] __attribute__((aligned(16))); \
16 RTYPE result_eq_##NAME[N] __attribute__((aligned(16))); \
17 STYPE operand1_##NAME[N] __attribute__((aligned(16))); \
18 STYPE operand2_##NAME[N] __attribute__((aligned(16))); \
19 RTYPE expected_##NAME[N] __attribute__((aligned(16))); \
21 __attribute__((noinline)) void vector_tests_##NAME () \
23 vector STYPE v1_##NAME, v2_##NAME; \
24 vector bool VBTYPE tmp_##NAME; \
26 for (i = 0; i < N; i+=16/sizeof (STYPE)) \
28 /* result_ne = operand1!=operand2. */ \
29 v1_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand1_##NAME[i]); \
30 v2_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand2_##NAME[i]); \
32 tmp_##NAME = vec_cmpeq (v1_##NAME, v2_##NAME); \
33 vec_vsx_st (tmp_##NAME, 0, &result_eq_##NAME[i]); \
35 tmp_##NAME = vec_cmpne (v1_##NAME, v2_##NAME); \
36 vec_vsx_st (tmp_##NAME, 0, &result_ne_##NAME[i]); \
40 __attribute__((noinline)) void init_##NAME () \
43 for (i = 0; i < N; ++i) \
45 result_ne_##NAME[i] = 7; \
46 result_eq_##NAME[i] = 15; \
50 operand1_##NAME[i] = 1; \
51 operand2_##NAME[i] = 2; \
56 operand1_##NAME[i] = 2; \
57 operand2_##NAME[i] = 1; \
62 operand1_##NAME[i] = 3; \
63 operand2_##NAME[i] = 3; \
65 /* For vector comparisons: "For each element of the result_ne, the \
66 value of each bit is 1 if the corresponding elements of ARG1 and \
67 ARG2 are equal." {or whatever the comparison is} "Otherwise, the \
68 value of each bit is 0." */ \
69 expected_##NAME[i] = -1 * (RTYPE)(operand1_##NAME[i] != operand2_##NAME[i]); \
73 __attribute__((noinline)) void verify_results_##NAME () \
76 for (i = 0; i < N; ++i) \
78 if ( ((result_ne_##NAME[i] != expected_##NAME[i]) || \
79 (result_ne_##NAME[i] == result_eq_##NAME[i]))) \
85 #define execute_test_functions(VBTYPE, RTYPE, STYPE, NAME) \
88 vector_tests_##NAME (); \
89 verify_results_##NAME (); \
93 define_test_functions (int, signed int, signed int, si
);
94 define_test_functions (int, unsigned int, unsigned int, ui
);
95 define_test_functions (short, signed short, signed short, ss
);
96 define_test_functions (short, unsigned short, unsigned short, us
);
97 define_test_functions (char, signed char, signed char, sc
);
98 define_test_functions (char, unsigned char, unsigned char, uc
);
99 define_test_functions (int, signed int, float, ff
);
103 execute_test_functions (int, signed int, signed int, si
);
104 execute_test_functions (int, unsigned int, unsigned int, ui
);
105 execute_test_functions (short, signed short, signed short, ss
);
106 execute_test_functions (short, unsigned short, unsigned short, us
);
107 execute_test_functions (char, signed char, signed char, sc
);
108 execute_test_functions (char, unsigned char, unsigned char, uc
);
109 execute_test_functions (int, signed int, float, ff
);