<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Loop vectorization: __restrict__ ignored ?"
   href="https://bugs.llvm.org/show_bug.cgi?id=38049">38049</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop vectorization: __restrict__ ignored ?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>m-takahiro@jp.fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following loop is not vectorized despite of using restrict specifier.

-----------------
extern double **xx1, **yy1, **zz1;

void foo_ng(const int M, const int N) {
  double (* __restrict__ x1)[M] = (double(*)[M]) xx1;
  double (* __restrict__ y1)[M] = (double(*)[M]) yy1;
  double (* __restrict__ z1)[M] = (double(*)[M]) zz1;

  for (int i = 0; i < N; ++i) {
    x1[0][i] = y1[0][i] + z1[0][i];
    x1[1][i] = y1[1][i] + z1[1][i];
  }
}
-----------------

$ clang --version
clang version 7.0.0 (trunk 336237)

$ clang -Ofast -Rpass=loop-vectorize test.c -Rpass-analysis=
loop-vectorize
test.c:8:3: remark: loop not vectorized: cannot prove it is safe to reorder
memory
      operations; allow reordering by specifying '#pragma clang loop
vectorize(enable)'
      before the loop. If the arrays will always be independent specify
'#pragma clang
      loop vectorize(assume_safety)' before the loop or provide the
'__restrict__'
      qualifier with the independent array arguments. Erroneous results will
occur if
      these options are incorrectly applied! [-Rpass-analysis=loop-vectorize]
  for (int i = 0; i < N; ++i) {


I added '#pragma clang loop vectorize(enable)' as the analysis message shows,
and the loop was vectorized. But, '__restrict__' is specified to the original
loop. So, I think it can be vectorized without pragma, but it wasn't
vectorized.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>