https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95674
--- Comment #3 from Vladimir Makarov <vmakarov at gcc dot gnu.org> --- I looked at this problem. All assignments are done in IRA (LRA does not change them). We can not make a better assignment because scratches do not permit to store any preferences from instruction constraints (pseudo-registers permits to do this). So storing and getting this info for scratches is the first step to solving the problem. LRA changes scratches to pseudo-registers to generate the correct code satisfying the insn constraints and turn them back to scratches when the corresponding pseudo-registers do not get hard registers. Moving change of scratches to pseudo-regs from LRA to IRA could help but it is a big work. Another solution is to not use scratches in machine-descriptions and use pseudo-registers instead. Scratches are bad and should be avoided as much as possible. I expressed this several times. Besides it is not possible to keep hard register preferences for them, they also can not be taken into account in conflict graph and this results in overoptimistic assignments which LRA has to correct.