GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
aarch64 Performance Win

AArch64: Limit the CINC exception in the if-conversion cost check

AArch64 if-conversion profitability check is refined to avoid over-optimizing sequences with increments.

The AArch64 backend’s if-conversion profitability check previously skipped cost analysis too broadly for sequences containing increments, often leading to unnecessary conversion of complex code blocks into conditional selects. This patch refines the check to only skip the cost analysis when the sequence consists of a single increment and a conditional select that directly uses it. This ensures that longer or more complex sequences with increments are subjected to proper cost evaluation, preventing suboptimal code generation and improving performance in certain loop scenarios.

In Details

The aarch64_noce_conversion_profitable_p function in GCC's AArch64 backend was too eager to skip the cost check for if-conversion candidates containing an instruction that increments a register. The original logic, looking at any ADD or SUB with a constant of 1, would allow lengthy sequences with multiple independent operations if they happened to contain such an increment. This was based on the assumption that such sequences would likely transform into a CSINC instruction. The fix restricts this exception to sequences that are *exactly* an increment followed by a single conditional s…

For Context
if-conversion
A compiler optimization technique that transforms conditional control flow (like if-else statements) into data flow using conditional instructions (like conditional selects) to potentially improve performance by reducing branch prediction misses.
CINC
Conditional Increment instruction on AArch64, often used as part of conditional selects.
CSINC
Conditional Select Increment instruction on AArch64. It conditionally selects a value and, if the condition is met, increments a register.
GIMPLE
GCC's internal representation (IR) for code, designed to be a three-address, pseudo-code like intermediate language.
Filed Under: aarch64optimizationif-conversiongcc