[llvm-bugs] [Bug 26465] New: [InstCombine] Replacing ((xor A, B) != 0) with (A != B) is not always good

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 3 14:54:47 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26465

            Bug ID: 26465
           Summary: [InstCombine] Replacing ((xor A, B) != 0) with (A !=
                    B) is not always good
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: twoh at fb.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160203/52c07a63/attachment-0001.html>


More information about the llvm-bugs mailing list