[llvm-bugs] [Bug 41340] New: And in cmp expanded too much

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 1 21:38:00 PDT 2019


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

            Bug ID: 41340
           Summary: And in cmp expanded too much
           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

int and_cmp(int x) {
    return (x & 2048) == 0;
}

Clang trunk:
and_cmp(int): # @and_cmp(int)
  mov eax, edi
  shr eax, 11
  not eax
  and eax, 1
  ret

Expected:
and_cmp(int):
        xor     eax, eax
        and     edi, 2048
        sete    al
        ret

The problem is the return type. If I change it to bool, I get:
and_cmp(unsigned int): # @and_cmp(unsigned int)
  test edi, 2048
  sete al
  ret

Clang should realize in the int case, that the range of the return value is i1
only. 

All -OX levels affected.

-- 
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/20190402/d65a086d/attachment.html>


More information about the llvm-bugs mailing list