> It looks at register that respect the constraints of all the instructions in > the set and tries to pick one in the preferred class for all the > instructions involved. This is generally useful for any pass that wants to > do register renaming. However it also contains some logic to only select > the register that also haven't been used for a longer time than the > register that should be replaced. This bit is specific to the register > renaming pass and makes the function unusable for this new pass as a result > which forces us to do a copy of the function. > > This patch adds an extra parameter to skip this check and only consider the > constraints and tries to pick a register in the preferred class.
OK on principle but... > 2014-11-14 Thomas Preud'homme <thomas.preudho...@arm.com> > > * regrename.c (find_best_rename_reg): Rename to ... > (find_rename_reg): This. Also add a parameter to skip tick check. > * regrename.h: Likewise. > * config/c6x/c6x.c: Adapt to above renaming. Missing function in config/c6x/c6x.c entry. > @@ -408,8 +410,13 @@ find_best_rename_reg (du_head_p this_head, enum > reg_class super_class, && ((pass == 0 > && !TEST_HARD_REG_BIT (reg_class_contents[preferred_class], > best_new_reg)) > - || tick[best_new_reg] > tick[new_reg])) > - best_new_reg = new_reg; > + || !best_rename || tick[best_new_reg] > tick[new_reg])) > + { > + if (best_rename) > + best_new_reg = new_reg; > + else > + return new_reg; > + } > } > if (pass == 0 && best_new_reg != old_reg) > break; Please write it like so: if (!check_new_reg_p (old_reg, new_reg, this_head, *unavailable)) continue; if (!best_rename) return new_reg; /* In the first pass, we force the renaming of registers that don't belong to PREFERRED_CLASS to registers that do, even though the latters were used not very long ago. * if ((pass == 0 && !TEST_HARD_REG_BIT (reg_class_contents[preferred_class], best_new_reg)) || tick[best_new_reg] > tick[new_reg])) best_new_reg = new_reg; -- Eric Botcazou