tree-optimization/127958 - avoid building invalid BIT_FIELD_REF
Fix redundant store elimination to avoid creating invalid bitfield references.
A bug in GCC’s redundant store elimination (within tree-ssa-sccvn.cc) could lead to the creation of invalid BIT_FIELD_REF expressions. This occurred because the offset for the temporary BIT_FIELD_REF was not constrained, causing subsequent operations that assumed a valid offset to fail. The fix ensures the offset fits within a poly_uint64 before it’s used, preventing an ICE (Internal Compiler Error).
In Details
The eliminate_dom_walker::eliminate_stmt function in tree-ssa-sccvn.cc, used for redundant store elimination, could construct a BIT_FIELD_REF with an offset that exceeded the representable range of poly_uint64. This would cause an ICE later when bit_field_offset was called on this invalid reference. This commit adds a check to ensure the offset is valid before the BIT_FIELD_REF is used for lookup, addressing PR tree-optimization/127958.
- redundant store elimination
- An optimization pass that removes store operations to memory locations if the value being stored is the same as a previous store to the same location and the location has not been modified in between.
- BIT_FIELD_REF
- A GCC Intermediate Representation (IR) node that accesses a bitfield within a larger value. It specifies an offset and a length for the bitfield.
- poly_uint64
- A type used in GCC for representing unsigned 64-bit integers that can also handle symbolic or unknown values, typically used in optimization contexts.
- ICE
- Internal Compiler Error. A crash within the compiler itself, usually indicating a bug in the compiler's logic or an unexpected input state.