https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89271
--- Comment #11 from Vladimir Makarov <vmakarov at gcc dot gnu.org> --- (In reply to Alan Modra from comment #5) > Created attachment 45760 [details] > Current set of patches > > It turns out there is a lot more than just wrong register_move_cost. This > patchset does fix the PR without introducing too many regressions, but it is > a work in progress. > > I have some questions about union register classes: > 1) What should register_move_cost return for a union class like > GEN_OR_VSX_REGS and some other class? Worst case, best case, or doesn't it > matter? > 2) What should preferred_reload_class return for union classes? > Looking at other ports doesn't shed much light.. IRA uses practically the same algorithm as the old RA. Only instead of pseudos, pseudo ranges (allocnos) are used. It is hard to describe the algorithm briefly. It has a few drawbacks. Roughly speaking it does not take into account that, when we calculate the costs, different pseudo operands should be on the same insn alternative. Choosing the classes implicitly affects on a final choice of insn alternative. For some time I worked on different approach which is based on choosing insn alternatives first and then calculating the costs. The code for this is currently on branch ira-select. As for register move costs inside an union class, for better RA results I think we should not take costs of moves between different subclasses into account. So it should be a minimal costs of moves only inside subclasses. For example, if we have GENERAL_FLOATING_REGS class the cost for moves inside the class (from GENERAL_FLOATING_REGS to GENERAL_FLOATING_REGS) should be not cost of move from GENERAL to FLOAT class but minimal cost of move only inside GENERAL class and only inside FLOAT class. Analogously, for moves between two different classes (when one or both classes are an union classes), we should use minimal cost of moves from subclasses of the two classes. The most common case when the algorithm chooses union classes is one when we use a pseudo to implement memory-memory move. For example, moving memory through general or float registers has the same cost. If we use maximal cost for moves between regs of GENERAL_FLOATING_REGS, the algorithm decreases the number of registers which can be used for such moves by using only general or only float regs. That is how I see the right approach but I never benchmarked different approaches, for example, on SPEC. So the approach I propose here has not been checked on practice.