https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128440
--- Comment #20 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by David Faust <[email protected]>: https://gcc.gnu.org/g:543fe22dd9ce221301e0176940ba9e1164b0c409 commit r14-13014-g543fe22dd9ce221301e0176940ba9e1164b0c409 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)
