https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118497
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Vladimir Makarov <vmaka...@gcc.gnu.org>: https://gcc.gnu.org/g:c4dae80357ccf2e035d8e9ec0a3bb319344c5b41 commit r15-7185-gc4dae80357ccf2e035d8e9ec0a3bb319344c5b41 Author: Vladimir N. Makarov <vmaka...@redhat.com> Date: Fri Jan 24 13:16:53 2025 -0500 [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.