<html>
    <head>
      <base href="https://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 --- - Bad instruction encoding in 32-bit code on haswell"
   href="https://llvm.org/bugs/show_bug.cgi?id=29010">29010</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bad instruction encoding in 32-bit code on haswell
          </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>All
          </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>andrew.b.adams@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16970" name="attach_16970" title=".ll that reproduces the issue">attachment 16970</a> <a href="attachment.cgi?id=16970&action=edit" title=".ll that reproduces the issue">[details]</a></span>
.ll that reproduces the issue

Some time in between r278315 and r278321 jitting 32-bit code for processors
with avx broke for me for some test cases (the generated code segfaults where
it didn't before).

The attached .ll file reproduces the problem with the following llc invocation:

$ llc test.ll -filetype=obj -O3 -mcpu=haswell -o  test.o

$ otool -tv test.o  | grep ld
000005f5    ldsl    0x7f8dd52a(%edx), %edi

The code faults at the ldsl instruction. Reading up on it, I don't think that's
an instruction that this .ll should be generating. Indeed if I get llvm to emit
asm directly I see no such instruction:

$ llc test.ll -filetype=asm -O3 -mcpu=haswell -o - | grep ldsl

Lining things up using the surrounding code, here's the block of asm from llc
-> asm directly:

        movl    4(%edi), %ebp
        addl    (%edi), %ebp
        vcvtsi2ssl      %ebp, %xmm8, %xmm2
        leal    4(%edi), %edi
        vmovss  %xmm2, (%edx)
        addl    $4, %edx

and here it is from llc -> object file -> otool:

000005f0        movl    0x4(%edi), %ebp
000005f3        addl    (%edi), %ebp
000005f5        ldsl    0x7f8dd52a(%edx), %edi
000005fb        addb    $-0x3b, %al
000005fd        cli
000005fe        adcl    %edx, (%edx)
00000600        addl    $0x4, %edx

So vcvtsi2ssl is messed up. Perhaps there's a problem with the instruction
encoding changes in that commit range?</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>