GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
pru

Pru: Ignore debug instructions when padding repeat loops

Fixes an issue where debug instructions caused extra NOPs in PRU repeat loops.

The pru_insert_loop_label_last function in the PRU backend incorrectly counted debug instructions as opcodes when calculating padding for repeat loops. This led to an extra NOP instruction being inserted. This change modifies the function to ignore debug instructions, ensuring correct padding and preventing unnecessary instructions. A new regression test was added to verify the fix.

In Details

The pru_insert_loop_label_last function in pru.cc determines loop padding by walking backward over the final two opcodes of a repeat loop. The INSN_P macro previously treated DEBUG_INSN as a valid opcode, causing the walk to terminate prematurely and insert an extra NOP. The fix replaces INSN_P with NONDEBUG_INSN_P to correctly exclude debug instructions from the opcode count, resolving an issue observed with -g -fno-var-tracking and PR127460.

For Context
PRU
Programmable Real-time Unit, a microcontroller core often used for real-time tasks alongside a host processor.
NOP
No Operation. An instruction that does nothing but consume processor cycles.
repeat loop
A control flow structure in PRU assembly that executes a block of code a specified number of times.
Filed Under: prucompileroptimization