<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 - X86CmovConversion ineffective when debug info is enabled"
   href="https://bugs.llvm.org/show_bug.cgi?id=34565">34565</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>X86CmovConversion ineffective when debug info is enabled
          </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>matthew.voss@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>rL308142 added a new optimization that converts cmov instructions to
combinations of
branch and mov instructions when the branch is well predicted 

Some of our internal testing highlighted a case where this optimization is
ineffective
when debug info is generated.  That is, when debug info is enabled, the cmov
instruction
is still generated.

A reduced IR repro is attached, both with and without debug info. Also, I've
included the
C++ file that was used to generate both of them.

Reproduce using:
    $ clang -O2 -c g.ll ; objdump -d --no-show-raw-insn g.o > g.dis
    $ clang -O2 -c no_g.ll ; objdump -d --no-show-raw-insn no_g.o > no_g.dis
    $ sdiff -w74 g.dis no_g.dis

    g.o:     file format elf64-x86-64   |   no_g.o:     file format elf64-x86-


    Disassembly of section .text.main:      Disassembly of section .text.main:

    0000000000000000 <main>:                0000000000000000 <main>:
       0:   push   %rbp                        0:   push   %rbp
       1:   mov    %rsp,%rbp                   1:   mov    %rsp,%rbp
       4:   push   %r15                        4:   push   %r15
       6:   push   %r14                        6:   push   %r14
       8:   push   %r12                        8:   push   %r12
       a:   push   %rbx                        a:   push   %rbx
       b:   mov    $0xa,%r14d           |      b:   mov    $0xa,%r15d
      11:   xor    %ebx,%ebx            |     11:   xor    %r12d,%r12d
      13:   lea    0x0(%rip),%r15       |     14:   lea    0x0(%rip),%r14
      1a:   nopw   0x0(%rax,%rax,1)     |     1b:   nopl   0x0(%rax,%rax,1)
      20:   lea    (%r14,%rbx,1),%r12d  |     20:   lea    (%r15,%r12,1),%ebx
      24:   callq  29 <main+0x29>             24:   callq  29 <main+0x29>
      29:   cltq                              29:   cltq
<span class="quote">>>>   2b:   cmp    %rax,(%r15,%r12,8)   |     2b:   cmp    %rax,(%r14,%rbx,8)
>>>   2f:   cmovae %r12d,%r14d          |     2f:   jb     40 <main+0x40>
>>>   33:   cmovb  %r12d,%ebx           |     31:   mov    %ebx,%r15d</span >
      37:   cmp    %r14d,%ebx           |     34:   cmp    %r15d,%r12d
      3a:   jb     20 <main+0x20>       |     37:   jb     20 <main+0x20>
      3c:   xor    %eax,%eax            |     39:   jmp    48 <main+0x48>
      3e:   pop    %rbx                 |     3b:   nopl   0x0(%rax,%rax,1)
      3f:   pop    %r12                 |     40:   mov    %ebx,%r12d
      41:   pop    %r14                 |     43:   cmp    %r15d,%r12d
      43:   pop    %r15                 |     46:   jb     20 <main+0x20>
      45:   pop    %rbp                 |     48:   xor    %eax,%eax
      46:   retq                        |     4a:   pop    %rbx
                                        >     4b:   pop    %r12
                                        >     4d:   pop    %r14
                                        >     4f:   pop    %r15
                                        >     51:   pop    %rbp
                                        >     52:   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>