<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 - Early loop unrolling causes missed SLP vectorization"
   href="https://bugs.llvm.org/show_bug.cgi?id=50552">50552</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Early loop unrolling causes missed SLP vectorization
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#include <stdint.h>

#include <cstddef>

#define STRIPE_WIDTH 32
#define STRIPE_MASK (STRIPE_WIDTH - 1)

static int16_t dither_line[2 * STRIPE_WIDTH] = {
#if STRIPE_WIDTH > 8
    8,  40, 8,  40, 8,  40, 8,  40, 8,  40, 8,  40, 8,  40, 8,  40,
    56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24,
#else
    8, 40, 8, 40, 8, 40, 8, 40, 56, 24, 56, 24, 56, 24, 56, 24,
#endif
};

void ass_stripe_pack_c(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src,
                       uintptr_t width, uintptr_t height) {
  uint8_t *ptr = dst;
  for (uintptr_t y = 0; y < height; ++y) {
    const int16_t *dither = dither_line + (y & 1) * STRIPE_WIDTH;
    for (int k = 0; k < STRIPE_WIDTH; ++k)
      ptr[k] = (uint16_t)(src[k] - (src[k] >> 8) + dither[k]) >> 6;

    ptr += dst_stride;
    src += STRIPE_WIDTH;
  }
  dst += STRIPE_WIDTH;
}


-O3 -fno-unroll-loops: Vectorized by Loop vectorizer
-O3: No vectorization by SLP

Current codegen:
<a href="https://godbolt.org/z/ocxbjx9ss">https://godbolt.org/z/ocxbjx9ss</a></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>