aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vcreate.c
blob: b8b338ef3c06ff2489b525e22760cbaed1fda335 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <arm_neon.h>
#include "arm-neon-ref.h"
#include "compute-ref-data.h"

/* Expected results.  */
VECT_VAR_DECL(expected,int,8,8) [] = { 0xf0, 0xde, 0xbc, 0x9a,
				       0x78, 0x56, 0x34, 0x12 };
VECT_VAR_DECL(expected,int,16,4) [] = { 0xdef0, 0x9abc, 0x5678, 0x1234 };
VECT_VAR_DECL(expected,int,32,2) [] = { 0x9abcdef0, 0x12345678 };
VECT_VAR_DECL(expected,int,64,1) [] = { 0x123456789abcdef0 };
VECT_VAR_DECL(expected,uint,8,8) [] = { 0xf0, 0xde, 0xbc, 0x9a,
					0x78, 0x56, 0x34, 0x12 };
VECT_VAR_DECL(expected,uint,16,4) [] = { 0xdef0, 0x9abc, 0x5678, 0x1234 };
VECT_VAR_DECL(expected,uint,32,2) [] = { 0x9abcdef0, 0x12345678 };
VECT_VAR_DECL(expected,uint,64,1) [] = { 0x123456789abcdef0 };
VECT_VAR_DECL(expected,poly,8,8) [] = { 0xf0, 0xde, 0xbc, 0x9a,
					0x78, 0x56, 0x34, 0x12 };
VECT_VAR_DECL(expected,poly,16,4) [] = { 0xdef0, 0x9abc, 0x5678, 0x1234 };
VECT_VAR_DECL(expected,hfloat,16,4) [] = { 0xdef0, 0x9abc, 0x5678, 0x1234 };
VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x9abcdef0, 0x12345678 };

#define INSN_NAME vcreate
#define TEST_MSG "VCREATE"

#define FNNAME1(NAME) void exec_ ## NAME (void)
#define FNNAME(NAME) FNNAME1(NAME)

FNNAME (INSN_NAME)
{
  /* Basic test: y=vcreate(x), then store the result.  */
#define TEST_VCREATE(T1, T2, W, N)					\
  VECT_VAR(vector_res, T1, W, N) = vcreate_##T2##W(VECT_VAR(val, T1, W, N)); \
  vst1_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))

#define DECL_VAL(VAR, T1, W, N)			\
  uint64_t VECT_VAR(VAR, T1, W, N)

  DECL_VAL(val, int, 8, 8);
  DECL_VAL(val, int, 16, 4);
  DECL_VAL(val, int, 32, 2);
  DECL_VAL(val, int, 64, 1);
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
  DECL_VAL(val, float, 16, 4);
#endif
  DECL_VAL(val, float, 32, 2);
  DECL_VAL(val, uint, 8, 8);
  DECL_VAL(val, uint, 16, 4);
  DECL_VAL(val, uint, 32, 2);
  DECL_VAL(val, uint, 64, 1);
  DECL_VAL(val, poly, 8, 8);
  DECL_VAL(val, poly, 16, 4);

  DECL_VARIABLE(vector_res, int, 8, 8);
  DECL_VARIABLE(vector_res, int, 16, 4);
  DECL_VARIABLE(vector_res, int, 32, 2);
  DECL_VARIABLE(vector_res, int, 64, 1);
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
  DECL_VARIABLE(vector_res, float, 16, 4);
#endif
  DECL_VARIABLE(vector_res, float, 32, 2);
  DECL_VARIABLE(vector_res, uint, 8, 8);
  DECL_VARIABLE(vector_res, uint, 16, 4);
  DECL_VARIABLE(vector_res, uint, 32, 2);
  DECL_VARIABLE(vector_res, uint, 64, 1);
  DECL_VARIABLE(vector_res, poly, 8, 8);
  DECL_VARIABLE(vector_res, poly, 16, 4);

  clean_results ();

  /* Initialize input values arbitrarily.  */
  VECT_VAR(val, int, 8, 8) = 0x123456789abcdef0LL;
  VECT_VAR(val, int, 16, 4) = 0x123456789abcdef0LL;
  VECT_VAR(val, int, 32, 2) = 0x123456789abcdef0LL;
  VECT_VAR(val, int, 64, 1) = 0x123456789abcdef0LL;
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
  VECT_VAR(val, float, 16, 4) = 0x123456789abcdef0LL;
#endif
  VECT_VAR(val, float, 32, 2) = 0x123456789abcdef0LL;
  VECT_VAR(val, uint, 8, 8) = 0x123456789abcdef0ULL;
  VECT_VAR(val, uint, 16, 4) = 0x123456789abcdef0ULL;
  VECT_VAR(val, uint, 32, 2) = 0x123456789abcdef0ULL;
  VECT_VAR(val, uint, 64, 1) = 0x123456789abcdef0ULL;
  VECT_VAR(val, poly, 8, 8) = 0x123456789abcdef0ULL;
  VECT_VAR(val, poly, 16, 4) = 0x123456789abcdef0ULL;

  TEST_VCREATE(int, s, 8, 8);
  TEST_VCREATE(int, s, 16, 4);
  TEST_VCREATE(int, s, 32, 2);
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
  TEST_VCREATE(float, f, 16, 4);
#endif
  TEST_VCREATE(float, f, 32, 2);
  TEST_VCREATE(int, s, 64, 1);
  TEST_VCREATE(uint, u, 8, 8);
  TEST_VCREATE(uint, u, 16, 4);
  TEST_VCREATE(uint, u, 32, 2);
  TEST_VCREATE(uint, u, 64, 1);
  TEST_VCREATE(poly, p, 8, 8);
  TEST_VCREATE(poly, p, 16, 4);

  CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
  CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
  CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
  CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, "");
  CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, "");
  CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, "");
  CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
  CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, "");
  CHECK(TEST_MSG, poly, 8, 8, PRIx8, expected, "");
  CHECK(TEST_MSG, poly, 16, 4, PRIx16, expected, "");
#if defined (__ARM_FP16_FORMAT_IEEE) || defined (__ARM_FP16_FORMAT_ALTERNATIVE)
  CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected, "");
#endif
  CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, "");
}

int main (void)
{
  exec_vcreate ();
  return 0;
}