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

Improve ext-dce's live bit tracking for IOR/AND with a constant argument

Improves dead code elimination by tracking live bits for IOR/AND operations with constant arguments.

This commit enhances the dead code elimination (DCE) pass by improving live bit tracking for logical IOR and AND operations with constant arguments. When bits are masked off or unconditionally turned on via these operations, the patch ensures that the masked-off bits are not considered live-in for the other input. This allows the compiler to eliminate unnecessary extension operations, leading to more optimized code, particularly on RISC-V.

In Details

The patch modifies ext-dce.cc to improve carry_backpropagate for AND and IOR operations with constant arguments. By tracking the liveness of bits after masking or unconditionally setting them, the pass can eliminate redundant extension operations. This change was triggered by a missed optimization on RISC-V, where a sext.w instruction was unnecessary due to subsequent masking.

For Context

Dead code elimination is an optimization that removes code that doesn't affect the program's output. This commit improves dead code elimination by more accurately tracking which bits of a variable are actually used (live bits). This allows the compiler to remove unnecessary operations that manipulate bits that are not used, resulting in smaller and faster code.

Filed Under: risc-voptimizationdead code elimination