[llvm-bugs] [Bug 47897] New: Avoid generation of __lshrti3 libcall for cold code

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 19 01:11:35 PDT 2020


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

            Bug ID: 47897
           Summary: Avoid generation of __lshrti3 libcall for cold code
           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, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

int a, b, c;
__attribute__((__cold__)) void d() { c = (unsigned __int128)a >> b; }

Clang -O3:
d():                                  # @d()
        push    rax
        movsxd  rdi, dword ptr [rip + a]
        mov     rsi, rdi
        sar     rsi, 63
        movzx   edx, byte ptr [rip + b]
        call    __lshrti3
        mov     dword ptr [rip + c], eax
        pop     rax
        ret
a:
        .long   0                               # 0x0

b:
        .long   0                               # 0x0

c:
        .long   0                               # 0x0



While Clang 11/GCC generates:
d():                                  # @d()
        movsxd  rax, dword ptr [rip + a]
        mov     rdx, rax
        sar     rdx, 63
        mov     cl, byte ptr [rip + b]
        shrd    rax, rdx, cl
        shr     rdx, cl
        test    cl, 64
        cmove   rdx, rax
        mov     dword ptr [rip + c], edx
        ret
a:
        .long   0                               # 0x0

b:
        .long   0                               # 0x0

c:
        .long   0                               # 0x0

https://godbolt.org/z/Kqf3EW

-- 
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/20201019/02ab5977/attachment.html>


More information about the llvm-bugs mailing list