[llvm-bugs] [Bug 38049] New: Loop vectorization: __restrict__ ignored ?

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 4 00:01:07 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38049

            Bug ID: 38049
           Summary: Loop vectorization: __restrict__ ignored ?
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: m-takahiro at jp.fujitsu.com
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180704/a917ec59/attachment.html>


More information about the llvm-bugs mailing list