Debian Codegraph @

gcc/testsuite/gcc.dg/vect/bb-slp-subgroups-3.c

raw
1 /* { dg-additional-options "-std=gnu17" } */
2 /* { dg-require-effective-target vect_int } */
3 /* { dg-require-effective-target vect_int_mult } */
4 /* PR tree-optimization/67682. */
5
6 #include "tree-vect.h"
7
8 int __attribute__((__aligned__(8))) a[8];
9 int __attribute__((__aligned__(8))) b[8];
10
11 __attribute__ ((noinline)) void
12 test ()
13 {
14 a[0] = b[0] + 1;
15 a[1] = b[1] + 2;
16 a[2] = b[2] + 3;
17 a[3] = b[3] + 4;
18 a[4] = b[0] * 3;
19 a[5] = b[2] * 4;
20 a[6] = b[4] * 5;
21 a[7] = b[6] * 7;
22 }
23
24 int
25 main (int argc, char **argv)
26 {
27 check_vect ();
28
29 for (int i = 0; i < 8; i++)
30 a[i] = 1;
31 for (int i = 0; i < 8; i++)
32 b[i] = i + 4;
33 __asm__ volatile ("" : : : "memory");
34 test (a, b);
35 __asm__ volatile ("" : : : "memory");
36 if ((a[0] != 5) || (a[1] != 7) || (a[2] != 9) || (a[3] != 11)
37 || (a[4] != 12) || (a[5] != 24) || (a[6] != 40) || (a[7] != 70))
38 abort ();
39 return 0;
40 }
41
42 /* { dg-final { scan-tree-dump-times "Basic block will be vectorized using SLP" 1 "slp2" } } */
43 /* Because we disable the cost model, targets with variable-length
44 vectors can end up vectorizing the store to a[0..7] on its own.
45 With the cost model we do something sensible. */
46 /* { dg-final { scan-tree-dump-times "optimized: basic block" 2 "slp2" { target { ! amdgcn-*-* } xfail { vect_variable_length && { ! vect128 } } } } } */
47
48 /* amdgcn can do this in one vector. */
49 /* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { target amdgcn-*-* } } } */