<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 --- - [InstCombine] Replacing ((xor A, B) != 0) with (A != B) is not always good"
   href="https://llvm.org/bugs/show_bug.cgi?id=26465">26465</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[InstCombine] Replacing ((xor A, B) != 0) with (A != B) is not always good
          </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>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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>twoh@fb.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>InstCombiner::visitICmpInstWithInstAndIntCst replaces ((xor A, B) != 0) with (A
!= B). However, this replacement generates suboptimal code if xor has uses
other than the compare. 

*** Example code

...
char c = lhs ^ rhs;
if (k == 0) return true;
if (k != 32) return false;
...

*** What LLVM generates now

movzbl (%rbx),%eax
movzbl %r8b,%ecx
cmp    %ecx,%eax
je     400c50
mov    %r8b,%cl
xor    %al,%cl
movzbl %cl,%ecx
cmp    $0x20,%ecx
jne    400cb0

*** What LLVM generates if the replacement performed only when xor has one use

mov    (%rbx),%al
mov    %r13b,%cl
xor    %al,%cl
je     400c48
movzbl %cl,%ecx
cmp    $0x20,%ecx
jne    400ca0</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>