<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] Illegal vector length reductions cause partial scalarization"
   href="https://bugs.llvm.org/show_bug.cgi?id=44478">44478</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] Illegal vector length reductions cause partial scalarization
          </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>andrea.dibiagio@gmail.com, craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://gcc.godbolt.org/z/zbkZUp">https://gcc.godbolt.org/z/zbkZUp</a>

clang -g0 -O3 -march=btver2

float sum4(int *x) {
    return x[0] + x[1] + x[2] + x[3];
}

float sum5(int *x) {
    return x[0] + x[1] + x[2] + x[3] + x[4];
}

_Z4sum4Pi: # @_Z4sum4Pi
  vmovdqu (%rdi), %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vcvtdq2ps %xmm0, %xmm0
  retq

_Z4sum5Pi: # @_Z4sum5Pi
  vmovdqu (%rdi), %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vmovd %xmm0, %eax
  addl 16(%rdi), %eax
  vcvtsi2ss %eax, %xmm1, %xmm0
  retq

It'd probably be better to keep sum5 etc. entirely on the vector unit and avoid
fpu<->gpu traffic

_Z4sum5Pi: # @_Z4sum5Pi
  vmovdqu (%rdi), %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vphaddd %xmm0, %xmm0, %xmm0
  vmovd 16(%rdi), %xmm1
  vpaddd %xmm1, %xmm0, %xmm0
  vcvtdq2ps %xmm0, %xmm0
  retq</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>