GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
final

Fix ICE for subreg offset on big-endian targets

Corrected an ICE on big-endian targets related to subregister offsets in the final backend.

An Internal Compiler Error (ICE) occurred on big-endian targets when handling a subregister with an outer QI mode and inner HI mode, specifically when the offset was 0. This was due to an invalid offset calculation. The fix replaces gen_rtx_SUBREG with gen_lowpart_SUBREG, which correctly computes the offset (1 for big-endian, 0 for little-endian), resolving the ICE.

In Details

The final.cc pass, specifically in test_output_operand_modifier_operand, experienced an ICE on big-endian targets when constructing a SUBREG where the outer mode was QI (8-bit) and the inner mode was HI (16-bit), with an offset of 0. This offset is invalid for big-endian byte ordering. The commit replaces gen_rtx_SUBREG with gen_lowpart_SUBREC, which correctly calculates the subregister offset considering the endianness and mode widths, resolving the ICE.

For Context
final
A GCC optimization pass that performs various transformations on the intermediate representation (tree) before generating machine code. It often handles instruction selection and register allocation details.
ICE
Internal Compiler Error. A condition where the compiler encounters an unexpected state or error during compilation and terminates.
Big-endian
A byte order where the most significant byte is stored at the lowest memory address.
Subreg
A subregister, which is a portion of a larger register. For example, the lower 16 bits of a 32-bit register can be a subregister.
QI mode
An internal GCC representation mode for an 8-bit quantity (e.g., a byte).
HI mode
An internal GCC representation mode for a 16-bit quantity (e.g., a short integer).
Filed Under: backendoptimizationbig-endianICE