view gcc/testsuite/gcc.dg/loop-versioning-6.c @ 157:dafe684d005c

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:08:54 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { 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" } } */