<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 - [PowerPC] icmp ne 0 can be implemented using the carry bit"
   href="https://bugs.llvm.org/show_bug.cgi?id=32520">32520</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PowerPC] icmp ne 0 can be implemented using the carry bit
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>spatel+llvm@rotateright.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I noticed this opportunity in <a href="https://reviews.llvm.org/D31483">https://reviews.llvm.org/D31483</a>.

This is from "Optimal Code Sequences" P. 200 of the Compiler Writer's Guide:

ne: not equal to r = v0 != v1;
subf R5,R3,R4 
addic R6,R5,-1 
subfe R7,R6,R5


define zeroext i1 @ne0(i32 %x) {
  %cmp = icmp ne i32 %x, 0
  ret i1 %cmp
}

Currently (r299396), the PPC backend seems to choose a cntlzw variant for all
compares against zero:

$ ./llc ne0.ll -o - -mtriple=powerpc64
        cntlzw 3, 3
        nor 3, 3, 3  <-- extended mnemonic for "not" would be nicer!
        rlwinm 3, 3, 27, 31, 31

I don't know anything about recent PPC uarch, so this may not be faster, but it
is smaller:

addic 4, 3, -1
subfe 3, 4, 3</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>