Update ix86_expand_movmem to return false if optimize_function_for_size_p
returns true to avoid inlining memmove for -Os.
gcc/
PR target/125355
* config/i386/i386-expand.cc (ix86_expand_movmem): Return false
for -Os.
gcc/testsuite/
PR target/125355
* gcc.target/i386/pr125355.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
{
/* Since there are much less registers available in 32-bit mode, don't
inline movmem in 32-bit mode. */
- if (!TARGET_64BIT)
+ if (!TARGET_64BIT || optimize_function_for_size_p (cfun))
return false;
rtx dst = operands[0];
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Os -mtune=generic" } */
+/* { dg-add-options check_function_bodies } */
+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
+
+/*
+**foo:
+**.LFB0:
+** .cfi_startproc
+** jmp memmove
+** .cfi_endproc
+**...
+*/
+
+#include <stddef.h>
+#include <string.h>
+
+void
+foo (char *d, char *s, size_t n)
+{
+ memmove(d, s, n);
+}