https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94298
--- Comment #5 from Vladimir Makarov <vmakarov at gcc dot gnu.org> --- I think that the root of the problem is that IRA on register cost calculation sub-pass chooses memory for the pseudo. It happens because the current algorithm (which is just an adoption of old recglass.c) considers insn alternatives for each operand independently of other operands. Roughly speaking, if we have insn with 2 alternatives and constraints 'r,m' for one operand and 'm,r' for another operand, the algorithm considers 'm' for the both operands (or 'r' for the both operands) are perfect (zero cost) match. I've tried to modify the current algorithm by small changes without a success. The full changes would result in what I have on ira-select branch. ira-select chooses an insn alternative and then calculate the costs taking this choice into account. Although move insns are a real challenge for such algorithm because they have too many alternatives. Switching to ira-select branch creates a lot of new testsuite failures on some targets for GCC tests expecting a specific code generation and actually does not improve overall SPEC rates on x86-64. I am thinking about combination of the two approaches but it is definitely not work which could be done for GCC10.