GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
sra Performance Win

SRA: Fix build_user_friendly_ref_for_offset for bit-fields

The compiler now correctly handles bit-field propagation with Scalar Replacement of Aggregates (SRA), improving warning accuracy and fixing a verification issu…

This commit fixes an issue in GCC’s Scalar Replacement of Aggregates (SRA) optimization when propagating bit-field accesses across assignments. The build_user_friendly_ref_for_offset function is updated to accurately represent the expression of new accesses, ensuring that warnings generated are correct. This resolves a discrepancy between the recorded size of the new access and the size reported by get_ref_base_and_extent, fixing a verifier error.

In Details

build_user_friendly_ref_for_offset in tree-sra.cc is used to represent expressions for new accesses during bit-field propagation in SRA. The function now tracks both the current size and the expected size to ensure they match, resolving a discrepancy and a verifier error. This fixes PR124151 and reverts a previous workaround for PR117217, which is no longer needed.

For Context

Scalar Replacement of Aggregates (SRA) is a compiler optimization that replaces parts of structures or classes with individual variables. This can improve performance by allowing the compiler to optimize these variables more effectively. This commit fixes an issue in how GCC handles bit-fields (variables that use only a few bits of storage) during SRA. The fix ensures that the compiler correctly tracks the size of bit-field accesses, leading to more accurate code generation and fewer errors.

Filed Under: optimizationsrabit-fieldsgcc