[llvm-bugs] [Bug 41326] New: Redundant extra XOR

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 31 13:49:34 PDT 2019


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

            Bug ID: 41326
           Summary: Redundant extra XOR
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

unsigned extra_xor(unsigned a, unsigned b)
{
    if (a == 0 || b == 0)
        return 0;

    unsigned y = 0;
    while (b != 0)
    {
        if (b & 1ul)
            y ^= a;
        a <<= 1;
        b >>= 1;
    }
    return y;
}

extra_xor(unsigned int, unsigned int):
        xor     eax, eax 
        test    edi, edi
        je      .LBB0_4
        test    esi, esi
        je      .LBB0_4
        xor     eax, eax <------- should be eliminated
.LBB0_3:                                
        mov     ecx, esi
        and     ecx, 1
        neg     ecx
        and     ecx, edi
        xor     eax, ecx
        add     edi, edi
        shr     esi
        jne     .LBB0_3
.LBB0_4:
        ret

-- 
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/20190331/ec6ed43e/attachment.html>


More information about the llvm-bugs mailing list