GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
alpha

Alpha TLS code generation improved by removing reload gate.

Alpha TLS code generation no longer gates a crucial check on `reload_completed`, fixing loop unrolling issues.

On the Alpha architecture, a check to prevent copying instructions (alpha_cannot_copy_insn_p) was incorrectly gated by reload_completed. This prevented the protection from applying to TLS (Thread-Local Storage) code generated before register allocation. This commit removes the gate, allowing the compiler to correctly handle TLS instruction pairs during loop unrolling and preventing assembler errors related to duplicate identifiers.

In Details

This patch modifies the alpha_cannot_copy_insn_p predicate in GCC's Alpha backend. Previously, this hook incorrectly returned false if !reload_completed, preventing it from guarding the cannot_copy attribute on TLS instruction pairs (like movdi_er_tlsgd and movdi_er_tlsldm) that are generated before register allocation. By removing the reload_completed check, the hook now correctly identifies and prohibits copying these TLS-related instruction sequences, resolving assembler errors (duplicate !tlsgd!1) that occurred with loop unrolling under specific optimization flags and `-fPIC…

For Context
Alpha
A 64-bit RISC instruction set architecture developed by Digital Equipment Corporation (DEC).
TLS (Thread-Local Storage)
A mechanism that allocates memory unique to each thread of execution. Changes to thread-local variables do not affect other threads.
reload_completed
A flag or state within GCC indicating that the register allocation phase (reload) has finished. Before this point, machine-dependent code generation hooks might behave differently.
loop unrolling
An optimization technique where multiple iterations of a loop are duplicated within the loop body to reduce loop overhead and potentially expose more instruction-level parallelism.
assembler
A program that translates assembly language code into machine code that a computer can execute.
Filed Under: alphatlsoptimization