aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/vec-cmpne.h
blob: a304de01d86bd077c00f1d08cb3b205fa409ea61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "altivec.h"

#define N 4096

void abort ();

#define PRAGMA(X) _Pragma (#X)
#define UNROLL0 PRAGMA (GCC unroll 0)

#define define_test_functions(VBTYPE, RTYPE, STYPE, NAME)	\
\
RTYPE result_ne_##NAME[N] __attribute__((aligned(16))); \
RTYPE result_eq_##NAME[N] __attribute__((aligned(16))); \
STYPE operand1_##NAME[N] __attribute__((aligned(16))); \
STYPE operand2_##NAME[N] __attribute__((aligned(16))); \
RTYPE expected_##NAME[N] __attribute__((aligned(16))); \
\
__attribute__((noinline)) void vector_tests_##NAME () \
{ \
  vector STYPE v1_##NAME, v2_##NAME; \
  vector bool VBTYPE tmp_##NAME; \
  int i; \
  UNROLL0 \
  for (i = 0; i < N; i+=16/sizeof (STYPE))	\
    { \
      /* result_ne = operand1!=operand2.  */ \
      v1_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand1_##NAME[i]); \
      v2_##NAME = vec_vsx_ld (0, (const vector STYPE*)&operand2_##NAME[i]); \
\
      tmp_##NAME = vec_cmpeq (v1_##NAME, v2_##NAME); \
      vec_vsx_st (tmp_##NAME, 0, &result_eq_##NAME[i]); \
\
      tmp_##NAME = vec_cmpne (v1_##NAME, v2_##NAME); \
      vec_vsx_st (tmp_##NAME, 0, &result_ne_##NAME[i]); \
    } \
} \

#define define_init_verify_functions(VBTYPE, RTYPE, STYPE, NAME) \
__attribute__((noinline)) void init_##NAME () \
{ \
  int i; \
  for (i = 0; i < N; ++i) \
    { \
      result_ne_##NAME[i] = 7; \
      result_eq_##NAME[i] = 15; \
      if (i%3 == 0) \
	{ \
	  /* op1 < op2.  */ \
	  operand1_##NAME[i] = 1; \
	  operand2_##NAME[i] = 2; \
	} \
      else if (i%3 == 1) \
	{ \
	  /* op1 > op2.  */ \
	  operand1_##NAME[i] = 2; \
	  operand2_##NAME[i] = 1; \
	} \
      else if (i%3 == 2) \
	{ \
	  /* op1 == op2.  */ \
	  operand1_##NAME[i] = 3; \
	  operand2_##NAME[i] = 3; \
	} \
      /* For vector comparisons: "For each element of the result_ne, the \
	  value of each bit is 1 if the corresponding elements of ARG1 and \
	  ARG2 are equal." {or whatever the comparison is} "Otherwise, the \
	  value of each bit is 0."  */ \
    expected_##NAME[i] = -1 * (RTYPE)(operand1_##NAME[i] != operand2_##NAME[i]); \
  } \
} \
\
__attribute__((noinline)) void verify_results_##NAME () \
{ \
  int i; \
  for (i = 0; i < N; ++i) \
    { \
      if ( ((result_ne_##NAME[i] != expected_##NAME[i]) || \
	    (result_ne_##NAME[i] == result_eq_##NAME[i]))) \
	abort (); \
    } \
}


#define execute_test_functions(VBTYPE, RTYPE, STYPE, NAME) \
{ \
  init_##NAME (); \
  vector_tests_##NAME (); \
  verify_results_##NAME (); \
}