[llvm-bugs] [Bug 41150] New: [SimplifyLibCalls] bad codegen for bcmp with constant inputs

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 20 01:35:36 PDT 2019


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

            Bug ID: 41150
           Summary: [SimplifyLibCalls] bad codegen for bcmp with constant
                    inputs
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: clement.courbet at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Example: (https://gcc.godbolt.org/z/pfvPCB)

#include <cstring>

static constexpr char k[] = "ABCDEFGH";
int F(char* p) {
    return memcmp(p, k, strlen(k)) == 0;
}

With clang 7, -O2:

F(char*):                                 # @F(char*)
        movabs  rcx, 5208208757389214273
        xor     eax, eax
        cmp     qword ptr [rdi], rcx
        sete    al
        ret

With trunk, -O2:
F(char*):                                 # @F(char*)
        push    rax
        mov     esi, offset k
        mov     edx, 8
        call    bcmp
        xor     ecx, ecx
        test    eax, eax
        sete    cl
        mov     eax, ecx
        pop     rcx
        ret
k:
        .asciz  "ABCDEFGH"

-- 
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/20190320/5f968c3b/attachment.html>


More information about the llvm-bugs mailing list