]> gcc.gnu.org Git - gcc.git/commitdiff
[RA]: Improve cost calculation of pseudos with equivalences
authorVladimir N. Makarov <vmakarov@redhat.com>
Thu, 14 Sep 2023 14:26:48 +0000 (10:26 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Thu, 14 Sep 2023 15:26:04 +0000 (11:26 -0400)
RISCV target developers reported that RA can spill pseudo used in a
loop although there are enough registers to assign.  It happens when
the pseudo has an equivalence outside the loop and the equivalence is
not merged into insns using the pseudo.  IRA sets up that memory cost
to zero when the pseudo has an equivalence and it means that the
pseudo will be probably spilled.  This approach worked well for i686
(different approaches were benchmarked long time ago on spec2k).
Although common sense says that the code is wrong and this was
confirmed by RISCV developers.

I've tried the following patch on I7-9700k and it improved spec17 fp
by 1.5% (21.1 vs 20.8) although spec17 int is a bit worse by 0.45%
(8.54 vs 8.58).  The average generated code size is practically the
same (0.001% difference).

In the future we probably need to try more sophisticated cost
calculation which should take into account that the equiv can not be
combined in usage insns and the costs of reloads because of this.

gcc/ChangeLog:

* ira-costs.cc (find_costs_and_classes): Decrease memory cost
by equiv savings.

gcc/ira-costs.cc

index d9e700e894736c598094bd50557199b1327fee80..8c93ace5094a94c4fb786258e712287be21f7d31 100644 (file)
@@ -1947,15 +1947,8 @@ find_costs_and_classes (FILE *dump_file)
            }
          if (i >= first_moveable_pseudo && i < last_moveable_pseudo)
            i_mem_cost = 0;
-         else if (equiv_savings < 0)
-           i_mem_cost = -equiv_savings;
-         else if (equiv_savings > 0)
-           {
-             i_mem_cost = 0;
-             for (k = cost_classes_ptr->num - 1; k >= 0; k--)
-               i_costs[k] += equiv_savings;
-           }
-
+         else
+           i_mem_cost -= equiv_savings;
          best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
          best = ALL_REGS;
          alt_class = NO_REGS;
This page took 0.066692 seconds and 5 git commands to generate.