https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112445
--- Comment #8 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:1390bf52c17a71834a1766c0222e4f8a74efb162 commit r14-6060-g1390bf52c17a71834a1766c0222e4f8a74efb162 Author: Vladimir N. Makarov <vmaka...@redhat.com> Date: Fri Dec 1 11:46:37 2023 -0500 [PR112445][LRA]: Fix "unable to find a register to spill" error PR112445 is a very complicated bug occurring from interaction of constraint subpass, inheritance, and hard reg live range splitting. It is hard to debug this PR only from LRA standard logs. Therefore I added dumping all func insns at the end of complicated sub-passes (constraint, inheritance, undoing inheritance, hard reg live range splitting, and rematerialization). As such output can be quite big, it is switched only one level 7 of -fira-verbose value. The reason for the bug is a skip of live-range splitting of hard reg (dx) on the 1st live range splitting subpass. Splitting is done for reload pseudos around an original insn and its reload insns but the subpass did not recognize such insn pattern because previous inheritance and undoing inheritance subpasses extended a bit reload pseudo live range. Although we undid inheritance in question, the result code was a bit different from a code before the corresponding inheritance pass. The following fixes the bug by restoring exact code before the inheritance. gcc/ChangeLog: PR target/112445 * lra.h (lra): Add one more arg. * lra-int.h (lra_verbose, lra_dump_insns): New externals. (lra_dump_insns_if_possible): Ditto. * lra.cc (lra_dump_insns): Dump all insns. (lra_dump_insns_if_possible): Dump all insns for lra_verbose >= 7. (lra_verbose): New global. (lra): Add new arg. Setup lra_verbose from its value. * lra-assigns.cc (lra_split_hard_reg_for): Dump insns if rtl was changed. * lra-remat.cc (lra_remat): Dump insns if rtl was changed. * lra-constraints.cc (lra_inheritance): Dump insns. (lra_constraints, lra_undo_inheritance): Dump insns if rtl was changed. (remove_inheritance_pseudos): Use restore reg if it is set up. * ira.cc: (lra): Pass internal_flag_ira_verbose. gcc/testsuite/ChangeLog: PR target/112445 * gcc.target/i386/pr112445.c: New test.