GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

Handle BIT_FIELD_REF in compute_access_stride

Loop interchange optimization now correctly analyzes bit-field references by using their base address.

This commit improves the compute_access_stride function within the loop interchange optimization. Previously, bit-field references (BIT_FIELD_REF) were not fully handled. The change ensures that for BIT_FIELD_REFs, the analysis now uses the address of its base for stride calculation, aligning its behavior with how loop interchange handles other bitfield accesses. A new test case is added.

In Details

The gimple-loop-interchange.cc pass compute_access_stride is used to analyze memory access patterns for loop transformations. This patch extends its analysis to handle BIT_FIELD_REF by dropping to the base address of the bitfield, similar to how other bitfield accesses are treated, ensuring more accurate stride analysis for loop interchange.

For Context
Loop Interchange
Loop interchange is an optimization technique that swaps the order of nested loops. This can improve data locality and enable other optimizations by restructuring array accesses to be more contiguous in memory.
BIT_FIELD_REF
A BIT_FIELD_REF refers to a specific bit field within a larger data structure. In GCC's GIMPLE intermediate representation, it represents an access to a part of a larger integer or structure member.
compute_access_stride
A function within GCC's loop optimization passes that calculates the stride of memory accesses within a loop. This information is crucial for determining if loop transformations like interchange or fusion are beneficial and safe.
Filed Under: optimizationloop interchangebitfield