x86: Avoid inlining cold memmove calls in size-optimised code.
GCC now avoids inlining calls to memmove when optimizing for size, for rarely-executed code paths on x86.
When compiling for size on x86, GCC was inlining calls to memmove even in rarely-executed code paths. This commit replaces optimize_function_for_size_p with optimize_insn_for_size_p in ix86_expand_movmem to prevent inlining of these cold memmove calls, reducing code size.
In Details
ix86_expand_movmem decides whether to inline small-object memmove calls, balancing call overhead against code size. This change refines its heuristics to respect optimization settings at the instruction level, avoiding inlining in rarely-executed paths (likely guarded by if conditions). Interaction with target-independent inlining heuristics are not obvious.
For Context
When compiling code, the compiler can optimize for different goals, such as speed or size. In some cases, the compiler might inline function calls to improve performance, but this can increase the code size. This commit prevents GCC from inlining calls to the memory copy function (memmove) in rarely-executed parts of the code when optimizing for size on x86, helping to keep the compiled program smaller. Inlining replaces a function call with the function's actual code, which avoids the overhead of a function call but increases the overall code size.