<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 - Slow code (-O2) due to using jne instead of using cmove"
   href="https://bugs.llvm.org/show_bug.cgi?id=45690">45690</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Slow code (-O2) due to using jne instead of using cmove
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Levo.DeLellis@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23403" name="attach_23403" title="The test cpp file">attachment 23403</a> <a href="attachment.cgi?id=23403&action=edit" title="The test cpp file">[details]</a></span>
The test cpp file

I attached my test file. I compiled with clang -O2 test.cpp -S

I notice branching in my code when I specifically wrote it so it wouldn't
branch. It jumped over a single instruction so I replaced it with a cmove. It
appears to cut this loop time in half

95,97c95
<       jne     .LBB1_8
< # %bb.7:                                #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
<span class="quote">>        cmove   %ecx, %edx</span >
105,107c103
<       jne     .LBB1_10
< # %bb.9:                                #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
<span class="quote">>        cmove   %ecx, %edx</span >
115,117c111
<       jne     .LBB1_12
< # %bb.11:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
<span class="quote">>        cmove   %ebx, %edx</span >
125,127c119
<       jne     .LBB1_14
< # %bb.13:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
<span class="quote">>        cmove   %ecx, %edx</span >
135,137c127
<       jne     .LBB1_16
< # %bb.15:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
<span class="quote">>        cmove   %ebx, %edx</span >
145,147c135
<       jne     .LBB1_18
< # %bb.17:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
<span class="quote">>        cmove   %ecx, %edx</span >
155,157c143
<       jne     .LBB1_20
< # %bb.19:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
<span class="quote">>        cmove   %ebx, %edx</span >
165,167c151
<       jne     .LBB1_22
< # %bb.21:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
<span class="quote">>        cmove   %ecx, %edx</span ></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>