GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
x86

x86: Avoid inlining memmove at -Os.

The compiler will no longer inline memmove when optimizing for size on x86, which should reduce code size.

The compiler will now avoid inlining calls to memmove when the -Os flag is used, which optimizes for size. This change prevents the compiler from expanding memmove inline, keeping the code smaller. A new test case was added to verify the change.

In Details

At -Os, GCC's code generator avoids function inlining where possible, to reduce the overall size of the generated binary. This commit teaches ix86_expand_movmem to respect that policy choice by returning false when optimize_function_for_size_p returns true.

For Context

When compiling code, there's often a trade-off between speed and size. Compilers can optimize for either, or try to strike a balance. Inlining a function means inserting the function's code directly into the calling code, which uses more space but avoids the overhead of a function call. This commit changes the inlining behavior of memmove (a function for copying blocks of memory) on x86 architectures when the compiler is told to optimize for size.

Filed Under: x86optimizationcode size