<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 --- - __builtin_expect(cond, 0) always produces CMOV under -O2"
   href="https://llvm.org/bugs/show_bug.cgi?id=27344">27344</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_expect(cond, 0) always produces CMOV under -O2
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>libclang
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>brian.armstrong.ece@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>klimek@google.com, 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=16215" name="attach_16215" title="Find minimum element of an array">attachment 16215</a> <a href="attachment.cgi?id=16215&action=edit" title="Find minimum element of an array">[details]</a></span>
Find minimum element of an array

I have an if statement with __builtin_expect where I expect the branch will be
taken very seldom. However, clang will always produce cmov instructions for
this branch. I suspect that branches will be faster for this particular case,
although I haven't been able to get clang to produce the branch version in
order to do the comparison.

Although I generally try to trust the compiler's judgment for these sorts of
matters, it would be nice to be able to compare the behavior for branches vs
cmov. In my particular program, I'm spending 25% of my CPU time on a pair of
cmovs similar to the snippet attached.</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>