https://gcc.gnu.org/g:a190f057070e0487b65f1ff630c8aba26bbdf114
commit r17-590-ga190f057070e0487b65f1ff630c8aba26bbdf114 Author: H.J. Lu <[email protected]> Date: Mon May 18 14:46:57 2026 +0800 x86: Don't inline cold memmove call Replace optimize_function_for_size_p with optimize_insn_for_size_p in ix86_expand_movmem to avoid inlining cold memmove call. gcc/ PR target/125355 * config/i386/i386-expand.cc (ix86_expand_movmem): Replace optimize_function_for_size_p with optimize_insn_for_size_p. gcc/testsuite/ PR target/125355 * gcc.target/i386/pr125355-2.c: New test. Signed-off-by: H.J. Lu <[email protected]> Diff: --- gcc/config/i386/i386-expand.cc | 2 +- gcc/testsuite/gcc.target/i386/pr125355-2.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 1a1d0652f885..6e07194e7167 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -10454,7 +10454,7 @@ ix86_expand_movmem (rtx operands[]) { /* Since there are much less registers available in 32-bit mode, don't inline movmem in 32-bit mode. */ - if (!TARGET_64BIT || optimize_function_for_size_p (cfun)) + if (!TARGET_64BIT || optimize_insn_for_size_p ()) return false; rtx dst = operands[0]; diff --git a/gcc/testsuite/gcc.target/i386/pr125355-2.c b/gcc/testsuite/gcc.target/i386/pr125355-2.c new file mode 100644 index 000000000000..b198c7debc81 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr125355-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mtune=generic" } */ +/* { dg-add-options check_function_bodies } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */ + +/* +**foo.cold: +**... +** call memmove +** call abort +** .cfi_endproc +**... +*/ + +#include <stddef.h> +#include <string.h> + +void +foo (char *d, char *s, size_t n) +{ + if (n < 80) + { + memmove (d, s, n); + __builtin_abort (); + } +}
