[llvm-bugs] [Bug 38929] New: Swap binop operands to avoid useless move before return

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 13 05:17:02 PDT 2018


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

            Bug ID: 38929
           Summary: Swap binop operands to avoid useless move before
                    return
           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: llvm-bugs at lists.llvm.org

unsigned f(unsigned x, unsigned y) {
    int p = (~x & y) | ~(x | y);
    // p =(x ^ y) | ~(x | y);
    return p;
}

Clang:
f(unsigned int, unsigned int):                                 # @f(unsigned
int, unsigned int)
        mov     eax, edi
        not     eax
        and     eax, esi
        or      esi, edi
        not     esi
        or      esi, eax   // or eax, edi
        mov     eax, esi   // not needed
        ret


GCC:
f(unsigned int, unsigned int):
        mov     eax, edi
        or      edi, esi
        not     eax
        not     edi
        and     eax, esi
        or      eax, edi
        ret

+ same for xor, etc...

-- 
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/20180913/981329d9/attachment.html>


More information about the llvm-bugs mailing list