[llvm-bugs] [Bug 47667] New: Loop with "# pragma clang loop interleave (enable)" is not interleaved

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 28 02:23:54 PDT 2020


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

            Bug ID: 47667
           Summary: Loop with "# pragma clang loop interleave (enable)" is
                    not interleaved
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: fj8765ah at aa.jp.fujitsu.com
                CC: llvm-bugs at lists.llvm.org

If you write "# pragma loop interleave (enable)" and "# pragma loop vectorize
(enable)" on the loop, the behavior is the same.
The reason is that they both create metadata like this:.

!8 = !{!"llvm.loop.vectorize.enable", i1 true}

Users will write these pragmas if they want to vectorize or interleave.
However, if "# pragma clang loop interleave (enable)" is specified, it is not
interleaved.
I think it should be interleaved. What do you think?

I think we should do one of the following two things.
* When the metadata described above exists, apply both vectorization and
interleaving.
* Create and control separate metadata for each.

It seems that interleaving is not controlled by the pragma but controlled by
the -funroll-loops option.

By the way, "# pragma clang loop interleave (disable)" is controlled by the
following metadata, so there is no problem.

!25 = !{!"llvm.loop.interleave.count", i32 1}


- interleave.c :
void foo(double * restrict a,
         double * restrict b,
         double * restrict c,
         int n) {

#pragma clang loop interleave(enable)
  for (int i=0;i<n;i++)
    c[i] = a[i] + b[i];

  return;
}

$ clang -O1 interleave.c -Rpass=loop-vector -S -Rpass-analysis=loop-vector
interleave.c:7:3: remark: the cost-model indicates that interleaving is
beneficial but is explicitly disabled or interleave count is set to 1
      [-Rpass-analysis=loop-vectorize]
  for (int i=0;i<n;i++)
  ^
interleave.c:7:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 1) [-Rpass=loop-vectorize] 
$ clang -O1 interleave.c -Rpass=loop-vector -S -funroll-loops
interleave.c:7:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 2) [-Rpass=loop-vectorize]
  for (int i=0;i<n;i++)
  ^

- vectorize.c :
void foo(double * restrict a,
         double * restrict b,
         double * restrict c,
         int n) {

#pragma clang loop vectorize(enable)
  for (int i=0;i<n;i++)
    c[i] = a[i] + b[i];

  return;
}

$ clang -O1 vectorize.c -Rpass=loop-vector -S -Rpass-analysis=loop-vector
vectorize.c:7:3: remark: the cost-model indicates that interleaving is
beneficial but is explicitly disabled or interleave count is set to 1
      [-Rpass-analysis=loop-vectorize]
  for (int i=0;i<n;i++)
  ^
vectorize.c:7:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 1) [-Rpass=loop-vectorize] 
$ clang -O1 vectorize.c -Rpass=loop-vector -S -funroll-loops
vectorize.c:7:3: remark: vectorized loop (vectorization width: 2, interleaved
count: 2) [-Rpass=loop-vectorize]
  for (int i=0;i<n;i++)
  ^

-- 
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/20200928/6ddb0c2c/attachment.html>


More information about the llvm-bugs mailing list