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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to