aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/loop-versioning-6.c
blob: e718c233502f4710c988a71ce31ebac45c1da195 (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
/* { dg-options "-O3 -fdump-tree-lversion-details" } */

/* The read from y in f1 will be hoisted to the outer loop.  In general
   it's not worth versioning outer loops when the inner loops don't also
   benefit.

   This test is meant to be a slight counterexample, since versioning
   does lead to cheaper outer-loop vectorization.  However, the benefit
   isn't enough to justify the cost.  */

void
f1 (double *restrict x, double *restrict y, int step, int n)
{
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      x[i + j] = y[i * step];
}

/* A similar example in which the read can't be hoisted, but could
   for example be handled by vectorizer alias checks.  */

void
f2 (double *x, double *y, int step, int n)
{
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      x[i + j] = y[i * step];
}

/* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */
/* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */