<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 --- - [PowerPC] could have used a CR-setting subtract"
   href="https://llvm.org/bugs/show_bug.cgi?id=31176">31176</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PowerPC] could have used a CR-setting subtract
          </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: 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>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>; ret = x > y ? x-y : 0
define i32 @max(i32 %x, i32 %y) {
  %sub = sub nsw i32 %x, %y
  %cmp = icmp sgt i32 %x, %y
  %sel = select i1 %cmp, i32 %sub, i32 0
  ret i32 %sel
}

$ ./llc -o - max.ll -mtriple=powerpc64 -mattr=isel
    subf 5, 4, 3    <--- use "subf."
    cmpw 0, 3, 4    <--- and eliminate this cmp
    li 3, 0
    isel 3, 5, 3, 1
    blr


There's a 2nd potential bug in this example: the 'li' could be removed because
isel RT,RA,RB,BC with RA=0 treats r0 as a zero operand?</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>