GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/auto-inc-dec

auto-inc-dec: Recomputes decision table per function for accurate target option handling

Auto-inc-dec pass now reinitializes its target-specific decision table for each function.

The auto-increment/decrement addressing pass previously computed its decision table once per translation unit. This led to incorrect behavior on architectures like ARM and RISC-V where target options affecting addressing modes (e.g., TARGET_32BIT, XTheadMemIdx) can change between functions. The pass now recomputes this table at the start of each function, ensuring correct selection of pre/post-modify addressing based on the current function’s target specifics.

In Details

The auto-inc-dec pass relies on a HAVE_{PRE,POST}_* macro-driven decision table, initialized once per TU. However, these macros can be target-option dependent (e.g., TARGET_32BIT on ARM, XTheadMemIdx on RISC-V). When target switches occur within a TU (e.g., target("thumb")), the cached table becomes stale. This commit clears and refills the table via init_decision_table on every execute call, adding a few dozen stores per function but ensuring correctness across target variants.

For Context
auto-increment/decrement addressing
A CPU addressing mode that automatically updates a register (e.g., an address pointer) after accessing memory, often used for efficient array traversal.
translation unit (TU)
A single source file after preprocessing, which the compiler processes as one unit.
target option
Compiler flags or settings that specify the target architecture, instruction set, or operating system, influencing code generation.
RISC-V
A free and open instruction set architecture (ISA) that is gaining traction in embedded systems and high-performance computing.
Filed Under: auto-inc-dectarget-optionsarmrisc-v