regtest: broaden none/tests/linux/bug498317 suppression for PPC
[valgrind.git] / none / tests / arm64 / simd_dotprod.c
blobca67da55108f014f49183e461be60d7de35b91da
1 #include <stdio.h>
2 #include <assert.h>
4 typedef unsigned char UChar;
5 typedef unsigned int UInt;
6 typedef signed int Int;
8 #define ITERS 1
10 union _V128 {
11 UChar u8[16];
13 typedef union _V128 V128;
15 static inline UChar randUChar ( void )
17 static UInt seed = 80021;
18 seed = 1103515245 * seed + 12345;
19 return (seed >> 17) & 0xFF;
22 /* Generates a random V128. */
23 static void randV128 ( /*OUT*/V128* v)
25 static UInt nCalls = 0;
26 Int i;
27 nCalls++;
28 for (i = 0; i < 16; i++) {
29 v->u8[i] = randUChar();
31 if (0 == (nCalls & 0xFF))
32 printf("randV128: %u calls\n", nCalls);
35 static void showV128 ( V128* v )
37 Int i;
38 for (i = 15; i >= 0; i--)
39 printf("%02x", (Int)v->u8[i]);
42 #define GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,SUFFIXM) \
43 Int i; \
44 for (i = 0; i < ITERS; i++) { \
45 V128 block[3]; \
46 randV128(&block[0]); \
47 randV128(&block[1]); \
48 randV128(&block[2]); \
49 __asm__ __volatile__( \
50 "ldr q7, [%0, #0];" \
51 "ldr q8, [%0, #16];" \
52 "ldr q9, [%0, #32];" \
53 #INSN " v9." #SUFFIXD ", v7." #SUFFIXN ", v8." SUFFIXM " ; " \
54 "str q9, [%0, #32];" \
55 : : "r"(&block[0]) : "memory", "v7", "v8", "v9" \
56 ); \
57 printf(#INSN " v9." #SUFFIXD \
58 ", v7." #SUFFIXN ", v8." SUFFIXM " "); \
59 showV128(&block[0]); printf(" "); \
60 showV128(&block[1]); printf(" "); \
61 showV128(&block[2]); printf("\n"); \
62 } \
64 #define GEN_BINARY_TEST_BY_ELEM(INSN,SUFFIXD,SUFFIXN,MELEM) \
65 __attribute__((noinline)) \
66 static void test_##INSN##_##SUFFIXD##_##SUFFIXN##_elem_##MELEM () { \
67 GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,"4b[" #MELEM "]") \
70 #define GEN_BINARY_TEST(INSN,SUFFIXD,SUFFIXN,SUFFIXM) \
71 __attribute__((noinline)) \
72 static void test_##INSN##_##SUFFIXD##_##SUFFIXN##_##SUFFIXM () { \
73 GEN_BINARY_TEST_BODY(INSN,SUFFIXD,SUFFIXN,#SUFFIXM) \
76 GEN_BINARY_TEST(sdot, 2s, 8b, 8b)
77 GEN_BINARY_TEST(udot, 2s, 8b, 8b)
78 GEN_BINARY_TEST(sdot, 4s, 16b, 16b)
79 GEN_BINARY_TEST(udot, 4s, 16b, 16b)
80 GEN_BINARY_TEST_BY_ELEM(sdot, 2s, 8b, 0)
81 GEN_BINARY_TEST_BY_ELEM(udot, 2s, 8b, 1)
82 GEN_BINARY_TEST_BY_ELEM(sdot, 4s, 16b, 2)
83 GEN_BINARY_TEST_BY_ELEM(udot, 4s, 16b, 3)
85 int main ( void )
87 assert(sizeof(V128) == 16);
89 // ======================== {S,U}DOT by element ====================
90 // sdot 2s,8b,4b[0]
91 // udot 2s,8b,4b[1]
92 // sdot 4s,16b,4b[2]
93 // udot 4s,16b,4b[3]
94 test_sdot_2s_8b_elem_0();
95 test_udot_2s_8b_elem_1();
96 test_sdot_4s_16b_elem_2();
97 test_udot_4s_16b_elem_3();
99 // ======================== {S,U}DOT vector ========================
100 // sdot 2s,8b,8b
101 // udot 2s,8b,8b
102 // sdot 4s,16b,16b
103 // udot 4s,16b,16b
104 test_sdot_2s_8b_8b();
105 test_udot_2s_8b_8b();
106 test_sdot_4s_16b_16b();
107 test_udot_4s_16b_16b();
109 return 0;