[llvm-bugs] [Bug 41173] New: Shifts on non negative numbers

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 21 02:27:34 PDT 2019


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

            Bug ID: 41173
           Summary: Shifts on non 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

int foo(int x) {
    if (x>=0) {
        unsigned xx = x;
        return xx >> 8;
    } else {
        return x >> 8;
    }
}

foo(int):                               # @foo3(int)
        mov     ecx, edi
        shr     ecx, 8
        mov     eax, edi
        sar     eax, 8
        test    edi, edi
        cmovns  eax, ecx
        ret


Maybe we can simplify foo to use just one shift?

-- 
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/20190321/7473e1dd/attachment-0001.html>


More information about the llvm-bugs mailing list