[llvm-bugs] [Bug 49028] New: Failure to optimize out test based on shr flags

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 3 16:04:04 PST 2021


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

            Bug ID: 49028
           Summary: Failure to optimize out test based on shr flags
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org

extern bool z;

uint16_t f(uint16_t m)
{
    m >>= 1;
    z = !m;
    return m;
}

On x86 -O3, GCC outputs this:

f(unsigned short):
  mov eax, edi
  shr ax
  sete BYTE PTR z[rip]
  ret

LLVM outputs this:

f(unsigned short):
  mov eax, edi
  shr eax
  test ax, ax
  sete byte ptr [rip + z]
  ret

The `test` seems like a net loss to me.

-- 
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/20210204/ae8aaf75/attachment.html>


More information about the llvm-bugs mailing list