Fix load combining peepholes for adjacent stack loads
Corrected x86 load combining to prevent reordering of loads around stores.
This commit fixes an issue in x86 load combining peepholes that could lead to incorrect instruction scheduling. When combining two adjacent stack loads into a wider V2DFmode load using adjust_address, the MEM_EXPR and MEM_ALIAS_SET were not properly updated. This allowed later scheduling passes to move the widened load before a preceding store, causing incorrect program behavior. The fix replaces adjust_address with widen_memory_access, which correctly updates MEM_EXPR and resets MEM_ALIAS_SET, while also adjusting operand checking to avoid merging loads from different parameters.
In Details
The x86 backend's peephole2 optimization for merging adjacent DFmode loads into V2DFmode loads was using adjust_address on stack-allocated memory. This left MEM_EXPR and MEM_ALIAS_SET unmodified, allowing the scheduler to incorrectly reorder the widened load before a store. This commit replaces adjust_address with widen_memory_access in config/i386/sse.md for the movsd/movhpd to movupd transformation. Additionally, ix86_operands_ok_for_move_multiple in config/i386/i386.cc is adjusted to prevent merging loads from distinct parameters, addressing PR127633.
- peephole optimization
- A compiler optimization technique that examines a small sequence (a 'peephole') of target machine instructions and replaces it with a more efficient sequence.
- DFmode
- GCC's internal mode for representing a double-precision floating-point number (typically 64 bits).
- V2DFmode
- GCC's internal mode for representing a vector of two double-precision floating-point numbers (typically 128 bits).
- MEM_EXPR
- An internal GCC representation for a memory operand in an expression.
- MEM_ALIAS_SET
- An internal GCC data structure used to track potential memory aliasing, crucial for optimization.
- widen_memory_access
- A GCC internal function that modifies a memory access to operate on a wider data type, ensuring correct handling of memory expressions and alias information.