Interestingly even when the preferences are accurate, lra_constraints completely ignores the preferred/allocno class. If the cost of 2 alternatives is equal in every way (which will be the case if they are both legal matches as the standard cost functions are not used at all), the wrong one may be chosen depending on the order in the MD file. This is particularly bad when the spill optimization pass later removes some of the spills and correctly allocates them to their preferred allocno class...
Forcing win = true if the register class of the alternative intersects with the preferred class generates significantly better spill code for cases where the preference is accurate (ie. not just ALL_REGS), resulting in far less confusion between integer and FP registers. So shouldn't get_reg_class return the preference/allocno class like below rather than NO_REGS? diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 0ddd842..f38914a 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -263,7 +263,10 @@ get_reg_class (int regno) } if (regno >= new_regno_start) return lra_get_allocno_class (regno); - return NO_REGS; + return reg_preferred_class (regno); } Wilco