GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

DOM avoids processing unreachable code with multiple SSA names.

The Dominator Optimiser now aborts processing unreachable code when a branch condition involves two SSA names, preventing incorrect global value assignments.

This commit modifies the Dominator Optimiser (DOM) to prevent it from attempting to assign global values to SSA names within unreachable code blocks, specifically when the branch condition leading to a __builtin_unreachable() has two SSA names. This change aligns DOM’s behavior with that of Value Range Propagation (VRP), avoiding potential issues where relations elsewhere in the code might invalidate global value assignments made in such unreachable paths. The fix is crucial for maintaining the correctness of optimizations, particularly when dealing with complex SSA relations.

In Details

The Dominator Optimiser (DOM) in tree-ssa-dom.cc works on the Static Single Assignment (SSA) form of the program's intermediate representation. It performs optimizations by analyzing the dominance relationships between basic blocks. set_global_ranges_from_unreachable_edges is a function within DOM that attempts to infer global value ranges based on unreachable code paths, specifically those terminated by __builtin_unreachable(). The issue arises when the conditional branch leading to such an unreachable block involves two distinct SSA names. In these cases, DOM's attempts to assign glob…

For Context

Compilers like GCC convert your source code into an intermediate form before generating the final machine code, and during this process, they perform many optimizations to make your program run faster. One such optimization technique involves something called "Static Single Assignment" (SSA) form, where every variable is assigned a value only once. Another optimization component is the Dominator Optimiser (DOM), which analyzes how different parts of your code affect each other. Sometimes, a programmer might use __builtin_unreachable() to tell the compiler that a certain part of the code should never be executed, usually to help the compiler optimize more aggressively. This change addresses a subtle problem where the DOM could make incorrect assumptions about the values of variables in these "unreachable" code paths if the condition leading to them involved two different SSA variables. By stopping the DOM from trying to assign global values in these tricky, unreachable scenarios, the…

Filed Under: optimizationssadominator-treebugfix