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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to