]> git.ipfire.org Git - thirdparty/gcc.git/commit
ifcvt: do not emit a store flag for an irreversible condition [PR126347]
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Tue, 21 Jul 2026 19:19:53 +0000 (21:19 +0200)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Thu, 23 Jul 2026 14:41:45 +0000 (16:41 +0200)
commitdcb8c8d3e7333b09081f81c29358e03e73d59a12
treea31223d522d26638b61591d89c0f7c5aa738f7d7
parenta9da59174f320570072e719d2c9e90def0f93b50
ifcvt: do not emit a store flag for an irreversible condition [PR126347]

noce_emit_store_flag feeds the possibly-reversed comparison code to a
store-flag insn, and to emit_store_flag, without checking that the
reversal succeeded.  reversed_comparison_code returns UNKNOWN for
UNLT/UNLE/UNGT/UNGE, and for a MODE_CC comparison it cannot trace back
to its COMPARE -- common for a floating-point condition on targets that
compare into a condition-code register.  emit_store_flag then reaches
its floating-point path and calls swap_condition (UNKNOWN), which aborts.

This was latent until r17-2519-ga33f26607eb4f3 made
noce_try_shifted_store_flag the first caller to reach
noce_emit_store_flag with REVERSEP set for such a condition.

Bail out early when the reversal failed.

Bootstrapped and regression tested on aarch64-unknown-linux-gnu with no
regressions.

PR rtl-optimization/126347
gcc/
* ifcvt.cc (noce_emit_store_flag): Return NULL_RTX when the
comparison code is UNKNOWN.
gcc/ifcvt.cc