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

Save edge in remove_unreachable to handle block splits.

GCC's `remove_unreachable` optimization now saves edges instead of endpoints to correctly handle code block splits.

The remove_unreachable optimization in GCC’s tree-ssa pass has been updated to save edges rather than block endpoints. This change ensures that the optimization correctly handles situations where basic blocks are split during the process. A new test case, pr126999.c, has been added to verify this fix.

In Details

The remove_unreachable pass in tree-vrp.cc previously stored block endpoints. This commit changes m_list to store edges instead, using std::pair<rtx, rtx> representing a basic block edge. This change is necessary because basic block splitting can invalidate endpoint information, while edge information remains valid. The maybe_register, remove, and remove_and_update_globals methods now correctly use the saved edge.

For Context
tree-ssa
Static Single Assignment form, an intermediate representation used within GCC. The 'tree' refers to the compiler's abstract syntax tree structure, and 'ssa' indicates that variables are assigned only once.
basic block
A contiguous sequence of basic instructions in a program where control flow enters at the beginning and leaves at the end without branching, except possibly at the end.
edge
In control flow graphs, an edge represents a possible transfer of control from one basic block to another.
Filed Under: optimizationrefactor