[llvm-bugs] [Bug 44469] New: [x86] x & ~0xFFFF could be emitted as 16-bit xor

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 6 04:58:42 PST 2020


            Bug ID: 44469
           Summary: [x86] x & ~0xFFFF could be emitted as 16-bit xor
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: tilkax 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

uint64_t foo(uint64_t x)
    return x & 0xFFFF'FFFF'FFFF'0000;

GCC:   xor ax, ax            (3 bytes)
Clang: and rax, 0xFFFF'0000  (6 bytes)

Same thing for 32-bit "x & 0xFFFF'0000".

As far as I'm aware the only reason 16-bit instructions are usually avoided is
because they always implicitly depend on the upper bits (but this dependency is
required here) and because the size override increases encoding length (not the
case here because it saves a 32-bit immediate).

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/20200106/cafaf202/attachment.html>

More information about the llvm-bugs mailing list