GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
i386

i386: Avoid scalar chain analysis on asm goto outputs

Prevents incorrect code generation by aborting scalar chain analysis when an `asm goto` output is not a simple fall-through definition.

This commit fixes a bug in the i386 backend where scalar chain analysis incorrectly handled outputs from asm goto statements. These outputs are defined on all control-flow edges, not just a fall-through path, which the scalar_chain::emit_conversion_insns function did not properly account for. This led to incorrect code or broken control-flow graphs. The fix involves aborting chain analysis when a non-convertible definition is associated with a jump instruction, resolving issues reported in PR125932.

In Details

When an asm goto statement in the i386 backend has outputs, these outputs are defined on all outgoing control-flow edges. However, scalar_chain::emit_conversion_insns assumes that definitions relevant to the chain are only present on the fall-through edge. This commit modifies scalar_chain::analyze_register_chain to detect when a non-convertible definition (like one from a jump instruction) is encountered and aborts the chain analysis. This prevents the misapplication of scalar chain logic to asm goto outputs, fixing incorrect code generation and CFG issues seen in PR125932.

For Context
asm goto
An extension to inline assembly that allows the assembly code to branch to a labeled C/C++ function or statement, enabling more control-flow-aware inline assembly.
scalar chain
A compiler intermediate representation that models sequences of operations on a single scalar value, often used to optimize register allocation and instruction scheduling.
control-flow graph (CFG)
A representation of all possible execution paths through a program. It consists of nodes (basic blocks of code) and edges (which represent possible transfers of control).
fall-through edge
In a control-flow graph, the edge representing the sequential execution of one basic block after another, without an explicit jump or branch.
Filed Under: i386asmcompiler bugcontrol flow