GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ext-dce Performance Win

ext-dce: Promote narrow operations to wider mode when extended bits are dead

The extended dead code elimination pass now promotes narrow operations to wider modes when extended bits are unused, which can enable better code generation on…

The extended dead code elimination (ext-dce) pass now promotes narrow operations (e.g., sign-extended addition) to wider modes when the extended bits are unused. This promotion enables the combine pass to recognize wider-mode operations, like DI-mode sequences, and form instructions such as sh1add, sh2add, and sh3add on RISC-V. This optimization is limited to chains of operations to avoid regressions on targets with free sign extension; single-instruction promotions are skipped.

In Details

This commit introduces fine-grained dead bit analysis to the ext-dce pass. When sign/zero extension of an arithmetic operation is followed by a use where the extended bits are dead, the inner operation is promoted to the wider mode. This uncovers opportunities for combine to form sh1add-like instructions on RISC-V. New structs (promotion_candidate_info, copy_info) and functions (ext_dce_try_promote_operation, ext_dce_record_promotion_candidate, ext_dce_promote_chained_candidates) are added to track promotion candidates and register connections within basic blocks.

For Context

This commit improves GCC's ability to optimize code by analyzing which parts of a number are actually used. When a program performs an operation on a small number and then extends it to a larger size, the compiler can now track whether the extra bits are actually used. If they aren't, the compiler can perform the operation directly on the larger size, which can lead to more efficient machine code, especially on RISC-V processors. This optimization is done carefully to avoid breaking existing optimizations.

Filed Under: optimizationdead code eliminationrisc-v