binutils Newspaper
OCTOBER 6, 2026
xtensa — Proposed

xtensa: fix MAX_ISTACK for loopgtz L32R widening

Increase MAX_ISTACK in Xtensa gas to 16 to accommodate loopgtz relaxation.

Alexey Lapshin proposes increasing MAX_ISTACK in the Xtensa assembler configuration from 12 to 16. This is necessary because the loopgtz relaxation sequence, which uses L32R widening, requires 13 instruction stack entries, causing overflows with the current limit. The patch also enhances overflow reporting and adds a new test case.

In the Thread 1 participant
  1. Alexey Lapshin proposer

    Submits a patch to increase `MAX_ISTACK` to 16 for Xtensa gas, fixing instruction stack overflows during `loopgtz` relaxation.

    “The loopgtz variant of that sequence needs 13 istack entries, but MAX_ISTACK remained 12, so relaxation of an out-of-range loopgtz overflowed the instruction stack. Increase MAX_ISTACK and report overflow with as_fatal that names MAX_ISTACK. Add a test.”

In Details

This patch addresses an overflow issue in the Xtensa assembler's instruction stack (istack) during loop relaxation. A recent change (commit 403b0b61f6d4) replaced loop widening with an L32R-based sequence. The loopgtz variant of this new sequence requires 13 entries on the instruction stack, but MAX_ISTACK was previously set to 12. This discrepancy caused the stack to overflow when relaxing out-of-range loopgtz instructions. The patch increases MAX_ISTACK to 16, provides more informative error messages for stack overflows, and adds a dedicated test case (loopgtz-relax.d and .s)…

For Context
Xtensa
A configurable processor architecture used in many embedded systems. Binutils provides support for generating code for Xtensa processors.
MAX_ISTACK
A macro defining the maximum size of the instruction stack used by the Xtensa assembler during relaxation and code generation.
loopgtz
A conditional branch instruction that jumps if a given value is greater than zero.
L32R
Load 32-bit Register. A type of instruction used in some architectures, including Xtensa, for loading 32-bit values into registers. It can be part of a sequence for handling wider immediate values.
relaxation
A process in assemblers and compilers where short, potentially fixed-position instructions are replaced with longer, more flexible ones (or vice-versa) to handle code that might be placed at different addresses in memory. This is common for optimizing branches and calls.
gas
The GNU Assembler, part of the GNU Binutils project. It translates assembly language code into machine code.
Filed Under: binutilsgasxtensaassembleroptimization