binutils Newspaper
OCTOBER 6, 2026
xtensa — Committed

xtensa: fix slow assembling of gcc.c-torture/compile/limits-externalid

Optimize Xtensa assembler by returning fragment range from branch target checks.

This commit optimizes the Xtensa assembler’s fragment processing by modifying next_frag_is_branch_target to return the end of the checked fragment range. This prevents redundant checks within loops, reducing the assembly time for specific torture tests from minutes to seconds. The change significantly improves performance for certain complex code generation scenarios.

In Details

The Xtensa assembler's xtensa_fix_target_frags function previously called next_frag_is_branch_target repeatedly. This function, which iterates through fragments to find branch targets or fixed frags, could lead to O(N^2) complexity. This patch optimizes it by having next_frag_is_branch_target return the valid_until fragment and by tracking the branch target status within xtensa_fix_target_frags for a range, thus calling the check function only once per relevant range.

For Context
fragment (frag)
A unit of code or data within the assembler's intermediate representation, typically corresponding to a machine instruction or data element.
branch target
A location in code that a branch instruction can jump to.
torture test
A test case designed to exercise a specific, often complex or edge-case, functionality of a compiler or assembler.
RELAX_DESIRE_ALIG
A specific fragment subtype used in the Xtensa assembler, likely related to alignment requirements.
Filed Under: xtensaperformancegasoptimization