alias.c: Remove unused headers.
[gcc.git] / gcc / ira-color.c
index 74d2c2ed6081c42c6dd8e56bbd121abbf7f26099..2e216955352384afd5e1d9a48702a2c282d930aa 100644 (file)
@@ -22,31 +22,18 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
-#include "predict.h"
-#include "tree.h"
+#include "target.h"
 #include "rtl.h"
+#include "tree.h"
+#include "predict.h"
 #include "df.h"
 #include "tm_p.h"
-#include "target.h"
-#include "regs.h"
-#include "flags.h"
-#include "alias.h"
 #include "insn-config.h"
-#include "expmed.h"
-#include "dojump.h"
-#include "explow.h"
-#include "calls.h"
-#include "emit-rtl.h"
-#include "varasm.h"
-#include "stmt.h"
-#include "expr.h"
-#include "diagnostic-core.h"
-#include "reload.h"
-#include "params.h"
-#include "cfgloop.h"
+#include "regs.h"
 #include "ira.h"
-#include "alloc-pool.h"
 #include "ira-int.h"
+#include "reload.h"
+#include "cfgloop.h"
 
 typedef struct allocno_hard_regs *allocno_hard_regs_t;
 
@@ -1157,7 +1144,7 @@ setup_profitable_hard_regs (void)
 
 /* Pool for update cost records.  */
 static object_allocator<update_cost_record> update_cost_record_pool
-  ("update cost records", 100);
+  ("update cost records");
 
 /* Return new update cost record with given params.  */
 static struct update_cost_record *
@@ -1311,10 +1298,12 @@ get_next_update_cost (ira_allocno_t *allocno, ira_allocno_t *from, int *divisor)
   return true;
 }
 
-/* Increase costs of HARD_REGNO by UPDATE_COST for ALLOCNO.  Return
-   true if we really modified the cost.  */
+/* Increase costs of HARD_REGNO by UPDATE_COST and conflict cost by
+   UPDATE_CONFLICT_COST for ALLOCNO.  Return true if we really
+   modified the cost.  */
 static bool
-update_allocno_cost (ira_allocno_t allocno, int hard_regno, int update_cost)
+update_allocno_cost (ira_allocno_t allocno, int hard_regno,
+                    int update_cost, int update_conflict_cost)
 {
   int i;
   enum reg_class aclass = ALLOCNO_CLASS (allocno);
@@ -1330,7 +1319,7 @@ update_allocno_cost (ira_allocno_t allocno, int hard_regno, int update_cost)
     (&ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (allocno),
      aclass, 0, ALLOCNO_CONFLICT_HARD_REG_COSTS (allocno));
   ALLOCNO_UPDATED_HARD_REG_COSTS (allocno)[i] += update_cost;
-  ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (allocno)[i] += update_cost;
+  ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (allocno)[i] += update_conflict_cost;
   return true;
 }
 
@@ -1342,7 +1331,7 @@ static void
 update_costs_from_allocno (ira_allocno_t allocno, int hard_regno,
                           int divisor, bool decr_p, bool record_p)
 {
-  int cost, update_cost;
+  int cost, update_cost, update_conflict_cost;
   machine_mode mode;
   enum reg_class rclass, aclass;
   ira_allocno_t another_allocno, from = NULL;
@@ -1383,11 +1372,20 @@ update_costs_from_allocno (ira_allocno_t allocno, int hard_regno,
          if (decr_p)
            cost = -cost;
 
-         update_cost = cp->freq * cost / divisor;
+         update_conflict_cost = update_cost = cp->freq * cost / divisor;
+
+         if (ALLOCNO_COLOR_DATA (another_allocno) != NULL
+             && (ALLOCNO_COLOR_DATA (allocno)->first_thread_allocno
+                 != ALLOCNO_COLOR_DATA (another_allocno)->first_thread_allocno))
+           /* Decrease conflict cost of ANOTHER_ALLOCNO if it is not
+              in the same allocation thread.  */
+           update_conflict_cost /= COST_HOP_DIVISOR;
+
          if (update_cost == 0)
            continue;
 
-         if (! update_allocno_cost (another_allocno, hard_regno, update_cost))
+         if (! update_allocno_cost (another_allocno, hard_regno,
+                                    update_cost, update_conflict_cost))
            continue;
          queue_update_cost (another_allocno, allocno, divisor * COST_HOP_DIVISOR);
          if (record_p && ALLOCNO_COLOR_DATA (another_allocno) != NULL)