[llvm-bugs] [Bug 46955] New: Missed simplification (A|C)^(B|C) ->

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 1 18:34:07 PDT 2020


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

            Bug ID: 46955
           Summary: Missed simplification (A|C)^(B|C) ->
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

#define C 4

unsigned int test(unsigned int A, unsigned  int B, unsigned int CC)

{

  return (A|C)^(B|C);
}


unsigned int test2(unsigned int A, unsigned  int B, unsigned int CC)

{

  return (A^B)&~C;
}

Clang

test(unsigned int, unsigned int, unsigned int):                             #
@test(unsigned int, unsigned int, unsigned int)
        mov     eax, esi
        or      edi, 4
        or      eax, 4
        xor     eax, edi
        ret
test2(unsigned int, unsigned int, unsigned int):                            #
@test2(unsigned int, unsigned int, unsigned int)
        mov     eax, edi
        xor     eax, esi
        and     eax, -5
        ret


GCC

test(unsigned int, unsigned int, unsigned int):
        xor     esi, edi
        mov     eax, esi
        and     eax, -5
        ret
test2(unsigned int, unsigned int, unsigned int):
        xor     edi, esi
        mov     eax, edi
        and     eax, -5
        ret

https://godbolt.org/z/3McGvb

-- 
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/20200802/c9b9ed51/attachment.html>


More information about the llvm-bugs mailing list