GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/sched-deps Performance Win

Improves scheduler efficiency by reusing register dependency arrays.

Reduces scheduler setup time by pooling and reusing register dependency data structures.

The GCC region scheduler previously allocated and zeroed new dependency descriptor arrays for each basic block within a region, leading to quadratic complexity in large functions. This commit introduces a pool for these deps_reg_entries arrays. After use, arrays are returned to the pool and reused for subsequent regions, significantly reducing allocation and zeroing overhead. This optimization improves compiler performance, particularly for large functions, with no impact on the generated code.

In Details

The region scheduler's initialization of deps_desc for each basic block involved allocating and zeroing max_reg deps_reg_entries. This resulted in O(max_reg * sum(blocks)) complexity, which could be quadratic in function size. This commit introduces a reg_last_pool to sched-deps.cc. After free_deps empties an entry, the array is returned to this pool, keyed by max_reg. Reused arrays have their list length fields reset. This optimization targets the scheduler's setup time, providing a compile-time performance improvement. A selftest verifies the pooling mechanism.

For Context
region scheduler
A phase in the compiler scheduler that groups basic blocks into regions to perform scheduling optimizations across block boundaries.
deps_desc
A data structure within GCC's scheduler that describes dependencies between instructions.
deps_reg_entries
An array of structures used by the scheduler to track register dependencies.
max_reg
The maximum number of registers available on the target architecture, used to size certain data structures in the compiler.
free_deps
A function within the scheduler that cleans up and releases dependency information.
Filed Under: optimizationschedulercompile-timegcc