<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - LLVM does not properly produce vectorized zextload instructions"
   href="http://llvm.org/bugs/show_bug.cgi?id=20443">20443</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM does not properly produce vectorized zextload instructions
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kree@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12823" name="attach_12823" title="Example .ll file deomonstrating problem with pmovzxbd">attachment 12823</a> <a href="attachment.cgi?id=12823&action=edit" title="Example .ll file deomonstrating problem with pmovzxbd">[details]</a></span>
Example .ll file deomonstrating problem with pmovzxbd

Hello, 

I believe that LLVM is not producing the optimal machine code in the case of a
zextload command on vectorized types. The basic problem I have is that when I
have a pair of instructions like: 

  %6 = load <4 x i8>* %5, align 16 
  %7 = zext <4 x i8> %6 to <4 x i32> 

LLVM produces the following assembly code: 

        pmovzxbd    (%rdi), %xmm0 
        pand    .LCPI0_0(%rip), %xmm0 

The pand here is unnecessary since pmovzxbd already ensures that the zext has
been done. I have attached a file "sse_pmovzx_test.ll" that demonstrates this
issue.

In the scalar case things work just fine, so if the above .ll code used scalar
types, we would get a single assembly line of the form: 

        movzbl    (%rdi), %eax 

It seems like the vector SSE operations are not matching against the zextload
pattern, and it looks like this could be intentional. In DAGCombiner.cpp I
found this comment: 

  // fold (zext (load x)) -> (zext (truncate (zextload x))) 
  // None of the supported targets knows how to perform load and vector_zext 
  // on vectors in one instruction.  We only perform this transformation on 
  // scalars. 
  if (ISD::isNON_EXTLoad(N0.getNode()) && !VT.isVector() && 
      ISD::isUNINDEXEDLoad(N0.getNode()) && 
      ((!LegalOperations && !cast<LoadSDNode>(N0)->isVolatile()) || 
       TLI.isLoadExtLegal(ISD::ZEXTLOAD, N0.getValueType()))) { 

So my question is what would it take to allow the combiner to make this
transformation for vector types? Is this comment out of date, since we now have
pmovzx** in SSE4.1 and vpmovzx** in AVX2?</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>