i386: Require reload_completed for AND -65536 split
Fixes i386 miscompile by ensuring register reload is complete before splitting AND -65536.
A miscompile on the i386 architecture is fixed by ensuring that a specific instruction split for and $-65536, reg only occurs after register reloading is complete. Previously, this split could happen prematurely, leading to incorrect handling of subregister values and a failure to update the intended register, causing the original register to retain an old, incorrect value.
In Details
i386 define_split for and $-65536, reg was firing too early. The split, which converts this to a strict_low_part HImode store of zero, could execute before reload. This resulted in gen_lowpart operating on a temporary pseudo, causing the strict_low_part store to update an unused pseudo and leave the original register unmodified. Requiring reload_completed ensures gen_lowpart operates on a hard register, yielding a plain REG that correctly aliases the original, resolving the miscompile.
- i386
- The architecture designation for the Intel 386 processor and its compatible successors, commonly referred to as x86.
- define_split
- A macro in GCC's machine description files that defines how a complex instruction pattern can be broken down into simpler ones during code generation.
- AND $-65536, reg
- An assembly instruction that performs a bitwise AND operation between a register and the immediate value -65536 (which is 0xFFFF0000 in 32-bit hexadecimal). This operation effectively zeros out the lower 16 bits of the register.
- reload_completed
- A state in GCC's compilation pipeline indicating that the register allocation and reloading phase for instructions has finished.
- HImode
- A GCC internal mode representing a short integer, typically 16 bits.
- strict_low_part
- A GCC instruction pattern that specifically targets the lower portion of a wider register or value, ensuring that only those bits are affected.
- subreg
- A subregister, which is a portion of a larger register that can be accessed independently.
- SI mode
- A GCC internal mode representing a single integer, typically 32 bits.
- pseudo
- A pseudo-register used by the compiler during intermediate stages of code generation, which is later mapped to a physical register or spilled to memory.