]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR119270][IRA]: Ignore equiv init insns for cost calculation for invariants only
authorVladimir N. Makarov <vmakarov@redhat.com>
Wed, 19 Mar 2025 20:06:41 +0000 (16:06 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Wed, 19 Mar 2025 20:10:37 +0000 (16:10 -0400)
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.

gcc/ira-costs.cc

index 70cba942a7b077c8ae96fdb9873337e4044e36a0..faf706ca5ddcc4a2c8ab0c868263f6d93df5a754 100644 (file)
@@ -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;