GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/tree-optimization

Ranger stmt prefill processes dependencies first

Fixes deep recursion in the Ranger optimization pass by correctly ordering dependency processing.

The Ranger optimization pass previously mishandled dependencies for PHI arguments, potentially leading to deep recursion and negating its intended benefits. This change revises the prefill logic to perform a Depth-First Search (DFS) on the dependency stack, ensuring all operands are processed correctly before proceeding. This resolves issues related to incorrect ordering and improves the pass’s stability.

In Details

The gimple_ranger::prefill_stmt_dependencies function in gimple-range.cc previously failed to account for PHI argument dependencies, leading to incorrect processing order and potential infinite recursion. This commit implements a DFS stack simulation to properly order operands, resolving PR tree-optimization/125758.

For Context
Ranger
A GCC optimization pass that analyzes and transforms code based on value ranges, aiming to simplify expressions and improve performance.
PHI argument
In SSA (Static Single Assignment) form, a PHI node represents a value that can come from multiple different control flow paths. It selects which predecessor's value to use based on the path taken.
DFS
Depth-First Search, an algorithm for traversing or searching tree or graph data structures. It explores as far as possible along each branch before backtracking.
gimple-range.cc
The GCC source file containing the implementation of the Ranger optimization pass and its related data structures and algorithms.
Filed Under: optimizationgcccompiler