https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125968

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <[email protected]>:

https://gcc.gnu.org/g:209757c5407dee80404800eff67e9dffb3430505

commit r17-1952-g209757c5407dee80404800eff67e9dffb3430505
Author: H.J. Lu <[email protected]>
Date:   Wed Jun 24 18:48:42 2026 +0800

    x86-64: Don't use overlapping unaligned moves to move 1 byte

    commit b41f96465190751561f6909e858604ceab00595b
    Author: H.J. Lu <[email protected]>
    Date:   Mon Oct 20 16:14:34 2025 +0800

    x86-64: Inline memmove with overlapping unaligned loads and stores.

    inlines memmove with overlapping unaligned and stores.  For

    void
    foo (char *dest, char *src, size_t len)
    {
      if (len <= 1)
        __builtin_memmove (dest, src, len);
    }

    it uses overlapping unaligned and stores to move 1 byte:

            cmpl    $1, %edx
            jb      .L1
            movl    %edx, %edx
            movzbl  (%rsi), %ecx
            movzbl  -1(%rsi,%rdx), %eax
            movb    %cl, (%rdi)
            movb    %al, -1(%rdi,%rdx)
            ret

    Don't call ix86_expand_n_overlapping_move_movmem when max size == 1 to
    generate:

            cmpl    $1, %edx
            jb      .L1
            movzbl  (%rsi), %eax
            movb    %al, (%rdi)
            ret

    gcc/

            PR target/125968
            * config/i386/i386-expand.cc (ix86_expand_movmem): Don't call
            ix86_expand_n_overlapping_move_movmem when max size == 1.

    gcc/testsuite/

            PR target/125968
            * gcc.target/i386/builtin-memmove-16.c: New test.
            * gcc.target/i386/builtin-memmove-17.c: Likewise.
            * gcc.target/i386/builtin-memmove-18a.c: Likewise.
            * gcc.target/i386/builtin-memmove-18b.c: Likewise.

    Signed-off-by: H.J. Lu <[email protected]>

Reply via email to