]> git.ipfire.org Git - thirdparty/gcc.git/commit
[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)
commit3c834d85f2ec42c60995c2b678196a06cb744959
tree9366fc58db6184750a7b0f1ccdfe3986554c9ead
parent6223ea766daf7c9155106b9784302442e2ff98d3
[RA]: Improve cost calculation of pseudos with equivalences

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