GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
compare-elim

compare-elim: Test successor's live-in set for flags register

Corrects compare-elim pass to accurately check flag register liveness across basic block boundaries.

The compare-elimination pass incorrectly checked the live-in set of the current basic block instead of its successor when determining if the flags register was used in a join block. This commit corrects the pass to query the successor’s live-in set, ensuring that comparisons whose flags are live across block boundaries are properly identified and handled, preventing potential issues in join blocks.

In Details

The find_comparisons_in_bb function in compare-elim.cc identifies comparisons whose flags are live-out of a basic block (BB) and live-in to a successor not part of the extended basic block. Previously, it queried DF_LIVE_BB_INFO(BB)->in instead of DF_LIVE_BB_INFO(DEST)->in (where DEST is the successor). This commit reverts to the correct check, ensuring that missing uses of flags in join blocks are correctly detected, particularly when flags are live across BB boundaries.

For Context
compare-elim
A compiler optimization pass that eliminates redundant comparison instructions by analyzing program flow and data dependencies. It aims to simplify the control flow graph and reduce overhead.
flags register
A special register (often part of the processor's status register) that holds the results of arithmetic and logical operations, such as zero, carry, or overflow flags, which are then used by conditional instructions.
basic block
A contiguous sequence of instructions in a program in which control flow enters at the beginning and leaves at the end without halt or possibility of branching except at the end.
live-in set
In liveness analysis, the set of variables or registers that hold values that are live (i.e., will be used later) upon entry to a particular basic block.
Filed Under: optimizationcompiler