aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/bb-slp-41.c
blob: 5a2bd4d2a33e41dbb33dc105b72f0ae6fd0e81ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* { dg-require-effective-target vect_int } */

#define ARR_SIZE 1000

void __attribute__((optimize (0)))
foo (int *a, int *b)
{
  int i;
  for (i = 0; i < (ARR_SIZE - 2); ++i)
    a[i] = b[0] + b[1] + b[i+1] + b[i+2];
}

/* Disable pre-slp FRE to avoid unexpected SLP on the epilogue
   of the 1st loop.  */
void __attribute__((optimize("-fno-tree-fre")))
bar (int *a, int *b)
{
  int i;
  for (i = 0; i < (ARR_SIZE - 2); ++i)
  {
    a[i] = b[0];
  }
  for (i = 0; i < (ARR_SIZE - 2); ++i)
  {
    a[i] = a[i] + b[1];
  }
  for (i = 0; i < (ARR_SIZE - 2); ++i)
  {
    a[i] = a[i] + b[i+1];
  }
  for (i = 0; i < (ARR_SIZE - 2); ++i)
  {
    a[i] = a[i] + b[i+2];
  }
}

int main ()
{
  int a1[ARR_SIZE];
  int a2[ARR_SIZE];
  int b[ARR_SIZE];
  int i;

  for (i = 0; i < ARR_SIZE; i++)
  {
    a1[i] = 0;
    a2[i] = 0;
    b[i]  = i;
  }

  foo (a1, b);
  bar (a2, b);

#pragma GCC novector
  for (i = 0; i < ARR_SIZE; i++)
    if (a1[i] != a2[i])
      return 1;

  return 0;

}
/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" "slp1" } } */