<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 --- - Bug in lowering of llvm.ctlz with vector arguments"
   href="http://llvm.org/bugs/show_bug.cgi?id=20917">20917</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bug in lowering of llvm.ctlz with vector arguments
          </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>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>avolkov.intel@gmail.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>avolkov.intel@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, zinovy.nis@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13025" name="attach_13025" title="Resulting assembler">attachment 13025</a> <a href="attachment.cgi?id=13025&action=edit" title="Resulting assembler">[details]</a></span>
Resulting assembler

For the following test case llc -mattr=+sse2 produces wrong code.

define <2 x i32> @test(<2 x i32> %x) {
  %1 = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %x, i1 false)
  ret <2 x i32> %1
}

declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1)

I attached resulting assembler.

The problem is in psubq instruction:
.LCPI0_1:
        .long   64                      # 0x40 <-- expected 32
        .long   0                       # 0x0
        .long   64                      # 0x40
        .long   0                       # 0x0
....
        psubq   .LCPI0_1, %xmm1</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>