The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119270
The patch was successfully bootstrapped and tested on x86_64 and aarch64.
commit 6c443e128802bd93158a3db7c4edf5fc1fc76c8d Author: Vladimir N. Makarov <vmaka...@redhat.com> Date: Wed Mar 19 16:06:41 2025 -0400 [PR119270][IRA]: Ignore equiv init insns for cost calculation for invariants only My previous patch for PR114991 contains code ignoring equiv init insns for increasing cost of usage the equivalence. Although common sense says it is right thing to do, this results in more aggressive usage of memory equivalence and significant performance degradation of SPEC2017 cactuBSSM. Given patch restores previous cost calculation for all equivalences except for invariant ones. gcc/ChangeLog: PR target/119270 * ira-costs.cc (calculate_equiv_gains): Ignore equiv init insns only for invariants. diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc index 70cba942a7b..faf706ca5dd 100644 --- a/gcc/ira-costs.cc +++ b/gcc/ira-costs.cc @@ -1926,12 +1926,15 @@ calculate_equiv_gains (void) || !bitmap_bit_p (&equiv_pseudos, regno)) continue; - rtx_insn_list *x; - for (x = ira_reg_equiv[regno].init_insns; x != NULL; x = x->next ()) - if (insn == x->insn ()) - break; - if (x != NULL) - continue; /* skip equiv init insn */ + if (ira_reg_equiv[regno].invariant != NULL) + { + rtx_insn_list *x = ira_reg_equiv[regno].init_insns; + for (; x != NULL; x = x->next ()) + if (insn == x->insn ()) + break; + if (x != NULL) + continue; /* skip equiv init insn for invariant */ + } rtx subst = ira_reg_equiv[regno].memory;