Debian Codegraph @

gcc/testsuite/gcc.dg/vect/pr65518.c

raw
1 #include "tree-vect.h"
2
3 #if VECTOR_BITS > 256
4 #define NINTS (VECTOR_BITS / 32)
5 #else
6 #define NINTS 8
7 #endif
8
9 #define N (NINTS * 2)
10 #define RESULT (NINTS * (NINTS - 1) / 2 * N + NINTS)
11
12 extern void abort (void);
13
14 typedef struct giga
15 {
16 unsigned int g[N];
17 } giga;
18
19 unsigned long __attribute__((noinline,noclone))
20 addfst(giga const *gptr, int num)
21 {
22 unsigned int retval = 0;
23 int i;
24 for (i = 0; i < num; i++)
25 retval += gptr[i].g[0];
26 return retval;
27 }
28
29 int main ()
30 {
31 struct giga g[NINTS];
32 unsigned int n = 1;
33 int i, j;
34 check_vect ();
35 for (i = 0; i < NINTS; ++i)
36 for (j = 0; j < N; ++j)
37 {
38 g[i].g[j] = n++;
39 __asm__ volatile ("");
40 }
41 if (addfst (g, NINTS) != RESULT)
42 abort ();
43 return 0;
44 }
45
46 /* We don't want to vectorize the single-element interleaving in the way
47 we currently do that (without ignoring not needed vectors in the
48 gap between gptr[0].g[0] and gptr[1].g[0]), because that's very
49 sub-optimal and causes memory explosion (even though the cost model
50 should reject that in the end). */
51
52 /* { dg-final { scan-tree-dump-times "vectorized 0 loops in function" 2 "vect" { target {! riscv*-*-* } } } } */
53 /* We should end up using gathers for the strided load on RISC-V. */
54 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { riscv*-*-* } } } } */
55 /* { dg-final { scan-tree-dump "using gather/scatter for strided/grouped access" "vect" { target { riscv*-*-* } } } } */