<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 --- - [AArch64] orr wzr vs. mov"
   href="https://llvm.org/bugs/show_bug.cgi?id=28966">28966</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AArch64] orr wzr vs. mov
          </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: AArch64
          </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>Forking this off <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [AArch64] missed opportunity to use conditional select invert (csinv)"
   href="show_bug.cgi?id=28965">bug 28965</a>. 

I can't imagine this would make any perf difference in practice, but it
suggests that there's some missing analysis/fold/pattern-matching because
functionally equivalent IR is producing different code:

$ cat cmpsel.ll
define i32 @goo(i32 %x) {
  %cmp = icmp eq i32 %x, 1
  %sel = select i1 %cmp, i32 1, i32 -1
  ret i32 %sel
}

define i32 @hoo(i32 %x) {
  %cmp = icmp ne i32 %x, 1  <--- inverse condition
  %sel = select i1 %cmp, i32 -1, i32 1  <--- swap select operands
  ret i32 %sel
}

$ ./llc -o - cmpsel.ll -mtriple=aarch64
goo:                                    // @goo
    cmp        w0, #1          // =1
    orr    w8, wzr, #0x1
    cneg     w0, w8, ne
    ret
hoo:                                    // @hoo
    cmp        w0, #1          // =1
    mov    w8, #-1
    cneg     w0, w8, eq
    ret</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>