[llvm-bugs] [Bug 47550] New: Missed optimization for range check for negative numbers

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 16 13:00:20 PDT 2020


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

            Bug ID: 47550
           Summary: Missed optimization for range check for negative
                    numbers
           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

bool rangecheck (int i, int x)
{
  return i > x && i < 0;
}



Clang:
rangecheck(int, int):                       # @rangecheck(int, int)
        cmp     edi, esi
        setg    cl
        test    edi, edi
        sets    al
        and     al, cl
        ret

GCC:
rangecheck(int, int):
        cmp     edi, esi
        setg    al
        shr     edi, 31
        and     eax, edi
        ret


https://godbolt.org/z/PPTP4o

-- 
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/20200916/674ce6e1/attachment.html>


More information about the llvm-bugs mailing list