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: unassignedb...@nondot.org
          Reporter: clement.cour...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to