<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 - Possible outer loop vectorization missed which is vectorized by GCC"
   href="https://bugs.llvm.org/show_bug.cgi?id=47035">47035</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Possible outer loop vectorization missed which is vectorized by GCC
          </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>normal
          </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>mauri_mustonen@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi!

I've been playing around with this simple code which outer loop is vectorized
by GCC just fine <a href="https://gcc.godbolt.org/z/hf6q58">https://gcc.godbolt.org/z/hf6q58</a>. This doesn't get vectorized
bt GCC if 'restrict' keyword is removed or inner loop count is not know at
compile time.

void foo1(const double* restrict in_a,
        const double* restrict in_b,
        double* restrict out)
{
    for (int i = 0; i < 100; ++i) {
        double a = in_a[i];
        double b = in_b[i];
        for (int j = 0; j < 10000; ++j) {
            a = a + b;
        }
        out[i] = a;
    }
}

GCC generated code use ymm registers to add 4 doubles at the same time and LLVM
generated code use xmm scalar registers to add one double at the time.

I've been reading vectorizer source code and I know LLVM only support innermost
loop vectorization. There are some plans for the vectorization plan (VPlan) to
enable outer loop vectorization in the future but couldn't find updates about
it and it seems quiet at the moment. So I'm also asking what is the status of
the VPlan or similar changes to enable outer loop vectorization in LLVM? And I
mean to contribute too, so I could also help with this support. Some pointers
about VPlan would be nice and is it still a valid plan?</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>