Debian Codegraph @

gcc/testsuite/gcc.dg/vect/bb-slp-77.c

raw
1
2 /* { dg-do compile } */
3 /* { dg-require-effective-target vect_int } */
4 #include <stdint.h>
5 #include <string.h>
6
7
8 typedef struct {
9 uint16_t d;
10 uint16_t m;
11 uint8_t val1[4];
12 uint8_t val2[16];
13 } st1;
14
15 typedef struct {
16 float d;
17 float s;
18 int8_t val2[32];
19 } st2;
20
21 float table[1 << 16];
22
23 inline static float foo(uint16_t f) {
24 uint16_t s;
25 memcpy(&s, &f, sizeof(uint16_t));
26 return table[s];
27 }
28
29
30 void test(const int n, float * restrict s, const void * restrict vx, const void * restrict vy) {
31 const int nb = n / 32;
32
33
34 const st1 * restrict x = vx;
35 const st2 * restrict y = vy;
36
37 float sumf = 0.0;
38
39 for (int i = 0; i < nb; i++) {
40 uint32_t val1;
41 memcpy(&val1, x[i].val1, sizeof(val1));
42
43 int sumi0 = 0;
44 int sumi1 = 0;
45
46 if (val1) {
47 for (int j = 0; j < 16; ++j) {
48 const uint8_t xh_0 = ((val1 >> (j)) << 4) & 0x10;
49 const uint8_t xh_1 = ((val1 >> (j + 12)) ) & 0x10;
50
51 const int32_t x0 = (x[i].val2[j] & 0xF) | xh_0;
52 const int32_t x1 = (x[i].val2[j] >> 4) | xh_1;
53
54 sumi0 += (x0 * y[i].val2[j]);
55 sumi1 += (x1 * y[i].val2[j + 16]);
56 }
57 } else {
58 for (int j = 0; j < 16; ++j) {
59 const int32_t x0 = (x[i].val2[j] & 0xF);
60 const int32_t x1 = (x[i].val2[j] >> 4);
61
62 sumi0 += (x0 * y[i].val2[j]);
63 sumi1 += (x1 * y[i].val2[j + 16]);
64 }
65 }
66
67 int sumi = sumi0 + sumi1;
68 sumf += (foo(x[i].d)*y[i].d)*sumi + foo(x[i].m)*y[i].s;
69 }
70
71 *s = sumf;
72 }
73
74 /* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp1" { target { { vect_int_mult && vect_element_align } && { ! { powerpc*-*-* x86_64-*-* i?86-*-* loongarch*-*-* s390*-*-* } } } } } } */