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

--- Comment #17 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by David Faust
<[email protected]>:

https://gcc.gnu.org/g:c0260aebc3e5ca7fb8e90b0ab6fba4d0e98bc4b7

commit r16-9941-gc0260aebc3e5ca7fb8e90b0ab6fba4d0e98bc4b7
Author: David Faust <[email protected]>
Date:   Tue Nov 10 12:40:57 2026 -0800

    bpf: fix memmove backward loops with remainders [PR128440]

    The backwards move loops emitted when expanding memmove were wrong if
    the loop had any remainder resulting in the wrong bytes being copied.
    For backwards loops the order of handling the alignment-sized chunks and
    remainder needs to be reversed.

    Add a new dedicated function emit_move_loop_back to handle the backwards
    move loops, and use it when appropriate.

    This patch also removes some unneeded code to update the remainder in
    emit_move_loop, as was pointed out in the PR.

            PR target/128440

    gcc/

            * config/bpf/bpf.cc (emit_move_loop): Remove buggy negative
            increment remainder handling.  Remove dead remainder updates.
            (emit_move_loop_backwards): New function.
            (bpf_expand_cpymem): Use it here instead of emit_move_loop with
            negative increment.

    gcc/testsuite/

            * gcc.target/bpf/memmove-5.c: New test.
            * gcc.target/bpf/memmove-6.c: New test.
            * gcc.target/bpf/memmove-7.c: New test.

    Suggested-by: <[email protected]>
    Signed-off-by: David Faust <[email protected]>
    (cherry picked from commit abb5fe17e1bb22f10cafc90f322577b0bcb41bb4)

Reply via email to