title: `restrict` ignored unless function manually inlined
body: <p>With GCC 9.4.0, the code</p>
  <pre class="lang-c prettyprint-override"><code>static inline double k(double const *restrict a) {
      return a[-1] + a[0] + a[1];
  }
  
  static void f(double const *restrict a, double *restrict b, int n) {
      for (int i = 0; i &lt; n; ++i) {
          b[i] = k(a);
      }
  }
  
  static inline void swap(double **a, double **b) {
      double *tmp = *a;
      *a = *b;
      *b = tmp;
  }
  
  void g(double * a, double * b, int n, int nt) {
      for (int t = 0; t &lt; nt; ++t) {
          f(a, b, n);
          swap(&amp;a, &amp;b);
      }
  }
  </code></pre>
  <p>results in <code>loop versioned for vectorization because of possible aliasing</code> for the loop in <code>f</code> when compiled using <code>gcc -march=native -Ofast -fopt-info-vec</code>, suggesting that the <code>restrict</code> qualifiers in <code>f</code> are being ignored.</p>
  <p>If I instead manually inline <code>k</code> into <code>f</code>:</p>
  <pre class="lang-c prettyprint-override"><code>static void f(double const *restrict a, double *restrict b, int n) {
      for (int i = 0; i &lt; n; ++i) {
          b[i] = a[-1] + a[0] + a[1];
      }
  }
  </code></pre>
  <p>the loop is vectorized without this versioning.</p>
  <p>In both cases GCC reports that all of the functions are automatically inlined into each other.</p>
  <p>The same occurs if I instead use <code>__restrict</code> and compile with <code>g++</code>.</p>
  <p>Why does this happen? Is there a cleanly portable (using standard language features) way of causing GCC to respect the <code>restrict</code> qualifiers in the first case so that I can benefit from vectorization without versioning, without separating <code>f</code> and <code>g</code> into different translation units?</p>