Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqabs.c

raw
1 #define INSN_NAME vqabs
2 #define TEST_MSG "VQABS/VQABSQ"
3
4 /* Extra tests for functions requiring corner cases tests. */
5 void vqabs_extra(void);
6 #define EXTRA_TESTS vqabs_extra
7
8 #include "unary_sat_op.inc"
9
10 /* Expected results. */
11 VECT_VAR_DECL(expected,int,8,8) [] = { 0x10, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9 };
12 VECT_VAR_DECL(expected,int,16,4) [] = { 0x10, 0xf, 0xe, 0xd };
13 VECT_VAR_DECL(expected,int,32,2) [] = { 0x10, 0xf };
14 VECT_VAR_DECL(expected,int,8,16) [] = { 0x10, 0xf, 0xe, 0xd,
15 0xc, 0xb, 0xa, 0x9,
16 0x8, 0x7, 0x6, 0x5,
17 0x4, 0x3, 0x2, 0x1 };
18 VECT_VAR_DECL(expected,int,16,8) [] = { 0x10, 0xf, 0xe, 0xd,
19 0xc, 0xb, 0xa, 0x9 };
20 VECT_VAR_DECL(expected,int,32,4) [] = { 0x10, 0xf, 0xe, 0xd };
21
22 /* Expected results when input is the min negative value of the type. */
23 VECT_VAR_DECL(expected_min_neg,int,8,8) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
24 0x7f, 0x7f, 0x7f, 0x7f };
25 VECT_VAR_DECL(expected_min_neg,int,16,4) [] = { 0x7fff, 0x7fff,
26 0x7fff, 0x7fff };
27 VECT_VAR_DECL(expected_min_neg,int,32,2) [] = { 0x7fffffff, 0x7fffffff };
28 VECT_VAR_DECL(expected_min_neg,int,8,16) [] = { 0x7f, 0x7f, 0x7f, 0x7f,
29 0x7f, 0x7f, 0x7f, 0x7f,
30 0x7f, 0x7f, 0x7f, 0x7f,
31 0x7f, 0x7f, 0x7f, 0x7f };
32 VECT_VAR_DECL(expected_min_neg,int,16,8) [] = { 0x7fff, 0x7fff,
33 0x7fff, 0x7fff,
34 0x7fff, 0x7fff,
35 0x7fff, 0x7fff };
36 VECT_VAR_DECL(expected_min_neg,int,32,4) [] = { 0x7fffffff, 0x7fffffff,
37 0x7fffffff, 0x7fffffff };
38
39 void vqabs_extra()
40 {
41 /* No need for 64 bits variants. */
42 DECL_VARIABLE(vector, int, 8, 8);
43 DECL_VARIABLE(vector, int, 16, 4);
44 DECL_VARIABLE(vector, int, 32, 2);
45 DECL_VARIABLE(vector, int, 8, 16);
46 DECL_VARIABLE(vector, int, 16, 8);
47 DECL_VARIABLE(vector, int, 32, 4);
48
49 DECL_VARIABLE(vector_res, int, 8, 8);
50 DECL_VARIABLE(vector_res, int, 16, 4);
51 DECL_VARIABLE(vector_res, int, 32, 2);
52 DECL_VARIABLE(vector_res, int, 8, 16);
53 DECL_VARIABLE(vector_res, int, 16, 8);
54 DECL_VARIABLE(vector_res, int, 32, 4);
55
56 clean_results ();
57
58 /* Initialize input "vector" with min negative values to check
59 saturation. */
60 VDUP(vector, , int, s, 8, 8, 0x80);
61 VDUP(vector, , int, s, 16, 4, 0x8000);
62 VDUP(vector, , int, s, 32, 2, 0x80000000);
63 VDUP(vector, q, int, s, 8, 16, 0x80);
64 VDUP(vector, q, int, s, 16, 8, 0x8000);
65 VDUP(vector, q, int, s, 32, 4, 0x80000000);
66
67 #define MSG "min negative input"
68 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 8, 8, MSG);
69 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 16, 4, MSG);
70 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 32, 2, MSG);
71 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, MSG);
72 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, MSG);
73 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, MSG);
74
75 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected_min_neg, MSG);
76 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_min_neg, MSG);
77 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_min_neg, MSG);
78 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected_min_neg, MSG);
79 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_min_neg, MSG);
80 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_min_neg, MSG);
81 }