x86: Avoid misaligned prologue if count <= epilogue size
Prevents misaligned prologue generation for small memory blocks on x86.
The x86 backend now prevents the use of a misaligned prologue when handling memory copy or set operations (ix86_expand_set_or_cpymem) if the block size is less than or equal to the epilogue size. This change addresses issues where vector instructions, designed for aligned data, could be used inappropriately on smaller blocks, potentially leading to performance degradation or incorrect behavior.
In Details
This commit modifies ix86_expand_set_or_cpymem to avoid using a misaligned prologue when the number of bytes to copy or set (count) is less than or equal to the size of the function epilogue. This condition was previously not handled, and the use of vector memory operations with a misaligned prologue on small blocks could lead to suboptimal code generation, possibly including incorrect behavior in edge cases related to block size and epilogue size alignment.
- misaligned prologue
- The initial part of a function's code that prepares the stack and registers. A 'misaligned prologue' implies that certain memory accesses within this setup might not be optimally aligned for performance, especially for vectorized operations.
- epilogue size
- The amount of stack space and register manipulation performed at the end of a function to restore the calling environment.
- vector instructions
- CPU instructions that perform the same operation on multiple data items simultaneously, often requiring data to be aligned in memory for optimal performance.
- x86
- A family of instruction set architectures commonly used in desktop and server processors.