https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126347
Bug ID: 126347
Summary: [17 Regression] ICE: in swap_condition, at jump.cc:625
during ce2 with a floating-point condition
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ptomsich at gcc dot gnu.org
Target Milestone: ---
As observed on ns3 (SPEC CPU 2026), after r17-2519-ga33f26607eb4f3 ("Improve
select across A/A OP C where C is 2^n", PR target/125731), if-conversion can
ICE on a floating-point condition:
during RTL pass: ce2
.../three-gpp-channel-model.cc:2449:1: internal compiler error: in
swap_condition, at jump.cc:625
swap_condition(rtx_code) gcc/jump.cc:625
emit_store_flag_1 gcc/expmed.cc:5872
emit_store_flag gcc/expmed.cc:6180
noce_emit_store_flag gcc/ifcvt.cc
noce_try_shifted_store_flag gcc/ifcvt.cc [<- new in the offending
commit]
noce_process_if_block / noce_find_if_block
To reproduce: building SPEC CPU 2017 753.ns3_r three-gpp-channel-model.cc at
-Ofast -flto -mcpu=ampere1 on aarch64 reliably ICEs.
We could not build a self-contained reproducer, as the failure needs the
CC-mode reversal trace to fail. This only occurs once cross-module inlining
separates the fcmp from the branch; single-function cases always trace and
don't reproduce.
Root cause: noce_emit_store_flag sets code = reversep ?
reversed_comparison_code(cond, jump) : GET_CODE(cond) and hands it to
emit_store_flag unchecked. reversed_comparison_code returns UNKNOWN for
UNLT/UNLE/UNGT/UNGE and for a MODE_CC compare it cannot trace back from the
jump (the usual case for an fp condition on CC-register targets).
noce_try_shifted_store_flag, added by r17-2519-ga33f26607eb4f3, is the first
caller to reach here with reversep for such a condition.