GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
ifcvt

ifcvt: Avoid store flag for irreversible conditions

Fixes ifcvt to not emit store flags for conditions that cannot be reliably reversed.

This change corrects an issue in GCC’s ifcvt optimization pass where it would incorrectly attempt to emit a store flag for comparisons that could not be reliably reversed. The noce_emit_store_flag function now checks for unknown comparison codes, preventing a crash when dealing with floating-point conditions on targets that use condition code registers.

In Details

The ifcvt.cc module has been updated to prevent noce_emit_store_flag from processing UNKNOWN comparison codes, which can arise from floating-point comparisons that don't map directly to a COMPARE instruction. This fix, prompted by PR rtl-optimization/126347, avoids calling swap_condition with UNKNOWN, thereby preventing an abort.

For Context
ifcvt
A GCC optimization pass (If-conversion) that transforms conditional branches into predicated instructions, potentially improving performance by reducing control flow.
store flag
In the context of conditional execution, a 'store flag' likely refers to a mechanism used to record the outcome of a comparison or condition that can be conditionally used later.
irreversible condition
A condition or comparison result that cannot be reliably transformed or reversed by the compiler's logic, leading to potential issues in optimization passes like ifcvt.
RTX
Register Transfer Language, an internal representation used by GCC to describe machine instructions and intermediate computations.
NULL_RTX
A special RTX value in GCC representing a null or non-existent operation or value.
Filed Under: ifcvtoptimizationrtlbugfix