(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
loop-versioning-6.c
       1  /* { dg-options "-O3 -fdump-tree-lversion-details" } */
       2  
       3  /* The read from y in f1 will be hoisted to the outer loop.  In general
       4     it's not worth versioning outer loops when the inner loops don't also
       5     benefit.
       6  
       7     This test is meant to be a slight counterexample, since versioning
       8     does lead to cheaper outer-loop vectorization.  However, the benefit
       9     isn't enough to justify the cost.  */
      10  
      11  void
      12  f1 (double *restrict x, double *restrict y, int step, int n)
      13  {
      14    for (int i = 0; i < n; ++i)
      15      for (int j = 0; j < n; ++j)
      16        x[i + j] = y[i * step];
      17  }
      18  
      19  /* A similar example in which the read can't be hoisted, but could
      20     for example be handled by vectorizer alias checks.  */
      21  
      22  void
      23  f2 (double *x, double *y, int step, int n)
      24  {
      25    for (int i = 0; i < n; ++i)
      26      for (int j = 0; j < n; ++j)
      27        x[i + j] = y[i * step];
      28  }
      29  
      30  /* { dg-final { scan-tree-dump-not {want to version} "lversion" } } */
      31  /* { dg-final { scan-tree-dump-not {versioned} "lversion" } } */