]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Don't inline cold memmove call
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 18 May 2026 06:46:57 +0000 (14:46 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 19 May 2026 06:57:53 +0000 (14:57 +0800)
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 <hjl.tools@gmail.com>
gcc/config/i386/i386-expand.cc
gcc/testsuite/gcc.target/i386/pr125355-2.c [new file with mode: 0644]

index 1a1d0652f88547d420003ea2ef8c875de8e4cdaa..6e07194e716723fe66e80b5bbbb135734755193f 100644 (file)
@@ -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 (file)
index 0000000..b198c7d
--- /dev/null
@@ -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 ();
+    }
+}