<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 - [X86] Terrible codegen for 'splatting' memory copies"
   href="https://bugs.llvm.org/show_bug.cgi?id=42024">42024</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] Terrible codegen for 'splatting' memory copies
          </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>Windows NT
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anton.a.afanasyev@gmail.com, craig.topper@gmail.com, lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, nikita.ppv@gmail.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm reporting this in X86 as we may be able to resolve much of it with better
costs and/or shuffle combining but the issue probably needs some fixes in the
vectorizers - we can reassign as necessary.

By splatting memory copy I mean a 1:N copy of each element, e.g. from a
grayscale to RGB uint8_t image copy:

template <typename T>
void splat3_copy(size_t n, T* __restrict dst, const T* __restrict src) {
    for (size_t i = 0; i < n; ++i) {
        auto s = src[i];
        dst[3*i+0] = s;
        dst[3*i+1] = s;
        dst[3*i+2] = s;
    }
}
void splat3_copy8(size_t h, size_t w, unsigned char* __restrict dst, const
unsigned char* __restrict src) {
    splat3_copy(h * w, dst, src);
}

<a href="https://gcc.godbolt.org/z/8X-TrN">https://gcc.godbolt.org/z/8X-TrN</a>

btver2 (AVX1) only uses individual byte loads + stores, while haswell (AVX2)
generates multiple vector loops of different sizes (with some pretty horrible
shuffles for what should be simple broadcasts+pshufb).</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>