diff options
Diffstat (limited to 'gcc/ira-costs.c')
-rw-r--r-- | gcc/ira-costs.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index 491b86bb841..39955b64693 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "addresses.h" #include "insn-config.h" #include "recog.h" +#include "reload.h" #include "toplev.h" #include "target.h" #include "params.h" @@ -123,6 +124,10 @@ static enum reg_class *pref_buffer; /* Record cover register class of each allocno with the same regno. */ static enum reg_class *regno_cover_class; +/* Record cost gains for not allocating a register with an invariant + equivalence. */ +static int *regno_equiv_gains; + /* Execution frequency of the current insn. */ static int frequency; @@ -1263,6 +1268,7 @@ find_costs_and_classes (FILE *dump_file) #ifdef FORBIDDEN_INC_DEC_CLASSES int inc_dec_p = false; #endif + int equiv_savings = regno_equiv_gains[i]; if (! allocno_p) { @@ -1311,6 +1317,15 @@ find_costs_and_classes (FILE *dump_file) #endif } } + if (equiv_savings < 0) + temp_costs->mem_cost = -equiv_savings; + else if (equiv_savings > 0) + { + temp_costs->mem_cost = 0; + for (k = 0; k < cost_classes_num; k++) + temp_costs->cost[k] += equiv_savings; + } + best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1; best = ALL_REGS; alt_class = NO_REGS; @@ -1680,6 +1695,8 @@ init_costs (void) regno_cover_class = (enum reg_class *) ira_allocate (sizeof (enum reg_class) * max_reg_num ()); + regno_equiv_gains = (int *) ira_allocate (sizeof (int) * max_reg_num ()); + memset (regno_equiv_gains, 0, sizeof (int) * max_reg_num ()); } /* Common finalization function for ira_costs and @@ -1687,6 +1704,7 @@ init_costs (void) static void finish_costs (void) { + ira_free (regno_equiv_gains); ira_free (regno_cover_class); ira_free (pref_buffer); ira_free (costs); @@ -1702,6 +1720,7 @@ ira_costs (void) init_costs (); total_allocno_costs = (struct costs *) ira_allocate (max_struct_costs_size * ira_allocnos_num); + calculate_elim_costs_all_insns (); find_costs_and_classes (ira_dump_file); setup_allocno_cover_class_and_costs (); finish_costs (); @@ -1802,3 +1821,16 @@ ira_tune_allocno_costs_and_cover_classes (void) } } } + +/* Add COST to the estimated gain for eliminating REGNO with its + equivalence. If COST is zero, record that no such elimination is + possible. */ + +void +ira_adjust_equiv_reg_cost (unsigned regno, int cost) +{ + if (cost == 0) + regno_equiv_gains[regno] = 0; + else + regno_equiv_gains[regno] += cost; +} |