GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
xtensa Performance Win

Define LOCAL_REGNO() macro for Xtensa TARGET_WINDOWED_ABI.

Fixes phantom DF livenesses and improves optimization in Xtensa.

This commit defines the LOCAL_REGNO() macro for the Xtensa target when the TARGET_WINDOWED_ABI option is enabled. Without this macro, the compiler incorrectly identifies phantom ‘DF’ (Data Flow) livenesses in the function epilogue. This incorrect liveness information hinders optimizations, such as low-overhead loop optimization, by causing the epilogue basic block to be incorrectly perceived as using loop variables. Defining LOCAL_REGNO() resolves this issue, enabling better optimization.

In Details

For the Xtensa architecture with TARGET_WINDOWED_ABI enabled, the absence of the LOCAL_REGNO() macro leads to incorrect liveness analysis in function epilogues. Register windows in Xtensa can hide registers, and LOCAL_REGNO() is intended to clarify which registers are local to the current function frame. Without it, the pass that tracks register liveness incorrectly flags registers used in the epilogue as live when they are not, interfering with optimizations like low-overhead loops. This patch defines LOCAL_REGNO() to resolve this liveness issue.

For Context
Xtensa
A configurable processor architecture for embedded systems. GCC provides a backend to generate code for Xtensa processors.
TARGET_WINDOWED_ABI
A configuration option for the Xtensa GCC backend that enables the use of register windows, a feature that can improve function call performance by reducing stack access.
LOCAL_REGNO()
A macro used in GCC to identify whether a given register number corresponds to a local register within the current function's frame, as opposed to a global or caller-save register. Its correct definition is crucial for accurate liveness analysis, especially with register windowing.
Liveness analysis
A compiler analysis that determines which variables or registers hold a value that might be used in the future. This information is critical for register allocation and other optimizations.
Function epilogue
The sequence of instructions at the end of a function that restores the caller's state, such as cleaning up the stack and returning control to the caller.
Filed Under: xtensaoptimizationabi