]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PR118497][IRA]: Fix calculation of cost of assigning callee-saved hard reg
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 24 Jan 2025 18:16:53 +0000 (13:16 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 24 Jan 2025 18:17:41 +0000 (13:17 -0500)
commitc4dae80357ccf2e035d8e9ec0a3bb319344c5b41
tree10f91713ae25bb2dff2e7a8f32a09afde2b245d1
parent10850f92b2a618ef1b1ad399530943ef4847823d
[PR118497][IRA]: Fix calculation of cost of assigning callee-saved hard reg

  Assembler code generated by GCC for PR118497 contains unnecessary
move insn.  This happened as IRA assigns AX reg to a pseudo which
should be in BX reg later for a call.  The pseudo did not get BX as
LRA decided that it requires to save BX although BX will be saved
anyway.  The patch fixes the cost calculation.  Usage of hard reg
nrefs from regstat or DF will result in numerous failures as such
nrefs include artificial reg refs.  Therefore we add a calculation of
hard reg nrefs in IRA.  Also we change regexp used for scanning the
assembler in test vartrack-1.c as with the patch LRA assigns
callee-saved hard reg BP instead of another callee-saved hard reg BX
expected by the test.

gcc/ChangeLog:

PR target/118497
* ira-int.h (target_ira_int): Add x_ira_hard_regno_nrefs.
(ira_hard_regno_nrefs): New macro.
* ira.cc (setup_hard_regno_aclass): Remove unused code.  Modify
the comment.
(setup_hard_regno_nrefs): New function.
(ira): Call it.
* ira-color.cc (calculate_saved_nregs): Check
ira_hard_regno_nrefs.

gcc/testsuite/ChangeLog:

PR target/118497
* gcc.target/i386/pr118497.c: New.
* gcc.target/i386/vartrack-1.c: Modify the regexp.
gcc/ira-color.cc
gcc/ira-int.h
gcc/ira.cc
gcc/testsuite/gcc.target/i386/pr118497.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vartrack-1.c