OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ira-build.c
index 00ddcb7..79bbe91 100644 (file)
@@ -33,7 +33,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "insn-config.h"
 #include "recog.h"
 #include "diagnostic-core.h"
-#include "toplev.h"
 #include "params.h"
 #include "df.h"
 #include "output.h"
@@ -94,15 +93,35 @@ int ira_copies_num;
    basic block.  */
 static int last_basic_block_before_change;
 
-/* The following function allocates the loop tree nodes.  If LOOPS_P
-   is FALSE, the nodes corresponding to the loops (except the root
-   which corresponds the all function) will be not allocated but nodes
-   will still be allocated for basic blocks.  */
+/* Initialize some members in loop tree node NODE.  Use LOOP_NUM for
+   the member loop_num.  */
 static void
-create_loop_tree_nodes (bool loops_p)
+init_loop_tree_node (struct ira_loop_tree_node *node, int loop_num)
+{
+  int max_regno = max_reg_num ();
+
+  node->regno_allocno_map
+    = (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t) * max_regno);
+  memset (node->regno_allocno_map, 0, sizeof (ira_allocno_t) * max_regno);
+  memset (node->reg_pressure, 0, sizeof (node->reg_pressure));
+  node->all_allocnos = ira_allocate_bitmap ();
+  node->modified_regnos = ira_allocate_bitmap ();
+  node->border_allocnos = ira_allocate_bitmap ();
+  node->local_copies = ira_allocate_bitmap ();
+  node->loop_num = loop_num;
+  node->children = NULL;
+  node->subloops = NULL;
+}
+
+
+/* The following function allocates the loop tree nodes.  If
+   CURRENT_LOOPS is NULL, the nodes corresponding to the loops (except
+   the root which corresponds the all function) will be not allocated
+   but nodes will still be allocated for basic blocks.  */
+static void
+create_loop_tree_nodes (void)
 {
   unsigned int i, j;
-  int max_regno;
   bool skip_p;
   edge_iterator ei;
   edge e;
@@ -123,17 +142,21 @@ create_loop_tree_nodes (bool loops_p)
       ira_bb_nodes[i].border_allocnos = NULL;
       ira_bb_nodes[i].local_copies = NULL;
     }
+  if (current_loops == NULL)
+    {
+      ira_loop_nodes = ((struct ira_loop_tree_node *)
+                       ira_allocate (sizeof (struct ira_loop_tree_node)));
+      init_loop_tree_node (ira_loop_nodes, 0);
+      return;
+    }
   ira_loop_nodes = ((struct ira_loop_tree_node *)
                    ira_allocate (sizeof (struct ira_loop_tree_node)
                                  * VEC_length (loop_p, ira_loops.larray)));
-  max_regno = max_reg_num ();
   FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
     {
       if (loop != ira_loops.tree_root)
        {
          ira_loop_nodes[i].regno_allocno_map = NULL;
-         if (! loops_p)
-           continue;
          skip_p = false;
          FOR_EACH_EDGE (e, ei, loop->header->preds)
            if (e->src != loop->latch
@@ -155,16 +178,7 @@ create_loop_tree_nodes (bool loops_p)
          if (skip_p)
            continue;
        }
-      ira_loop_nodes[i].regno_allocno_map
-       = (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t) * max_regno);
-      memset (ira_loop_nodes[i].regno_allocno_map, 0,
-             sizeof (ira_allocno_t) * max_regno);
-      memset (ira_loop_nodes[i].reg_pressure, 0,
-             sizeof (ira_loop_nodes[i].reg_pressure));
-      ira_loop_nodes[i].all_allocnos = ira_allocate_bitmap ();
-      ira_loop_nodes[i].modified_regnos = ira_allocate_bitmap ();
-      ira_loop_nodes[i].border_allocnos = ira_allocate_bitmap ();
-      ira_loop_nodes[i].local_copies = ira_allocate_bitmap ();
+      init_loop_tree_node (&ira_loop_nodes[i], loop->num);
     }
 }
 
@@ -176,10 +190,11 @@ more_one_region_p (void)
   unsigned int i;
   loop_p loop;
 
-  FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
-    if (ira_loop_nodes[i].regno_allocno_map != NULL
-       && ira_loop_tree_root != &ira_loop_nodes[i])
-      return true;
+  if (current_loops != NULL)
+    FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
+      if (ira_loop_nodes[i].regno_allocno_map != NULL
+         && ira_loop_tree_root != &ira_loop_nodes[i])
+       return true;
   return false;
 }
 
@@ -206,8 +221,11 @@ finish_loop_tree_nodes (void)
   unsigned int i;
   loop_p loop;
 
-  FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
-    finish_loop_tree_node (&ira_loop_nodes[i]);
+  if (current_loops == NULL)
+    finish_loop_tree_node (&ira_loop_nodes[0]);
+  else
+    FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
+      finish_loop_tree_node (&ira_loop_nodes[i]);
   ira_free (ira_loop_nodes);
   for (i = 0; i < (unsigned int) last_basic_block_before_change; i++)
     {
@@ -228,30 +246,39 @@ finish_loop_tree_nodes (void)
 \f
 
 /* The following recursive function adds LOOP to the loop tree
-   hierarchy.  LOOP is added only once.  */
+   hierarchy.  LOOP is added only once.  If LOOP is NULL we adding
+   loop designating the whole function when CFG loops are not
+   built.  */
 static void
 add_loop_to_tree (struct loop *loop)
 {
+  int loop_num;
   struct loop *parent;
   ira_loop_tree_node_t loop_node, parent_node;
 
   /* We can not use loop node access macros here because of potential
      checking and because the nodes are not initialized enough
      yet.  */
-  if (loop_outer (loop) != NULL)
+  if (loop != NULL && loop_outer (loop) != NULL)
     add_loop_to_tree (loop_outer (loop));
-  if (ira_loop_nodes[loop->num].regno_allocno_map != NULL
-      && ira_loop_nodes[loop->num].children == NULL)
+  loop_num = loop != NULL ? loop->num : 0;
+  if (ira_loop_nodes[loop_num].regno_allocno_map != NULL
+      && ira_loop_nodes[loop_num].children == NULL)
     {
       /* We have not added loop node to the tree yet.  */
-      loop_node = &ira_loop_nodes[loop->num];
+      loop_node = &ira_loop_nodes[loop_num];
       loop_node->loop = loop;
       loop_node->bb = NULL;
-      for (parent = loop_outer (loop);
-          parent != NULL;
-          parent = loop_outer (parent))
-       if (ira_loop_nodes[parent->num].regno_allocno_map != NULL)
-         break;
+      if (loop == NULL)
+       parent = NULL;
+      else
+       {
+         for (parent = loop_outer (loop);
+              parent != NULL;
+              parent = loop_outer (parent))
+           if (ira_loop_nodes[parent->num].regno_allocno_map != NULL)
+             break;
+       }
       if (parent == NULL)
        {
          loop_node->next = NULL;
@@ -300,21 +327,13 @@ setup_loop_tree_level (ira_loop_tree_node_t loop_node, int level)
 static void
 form_loop_tree (void)
 {
-  unsigned int i;
   basic_block bb;
   struct loop *parent;
   ira_loop_tree_node_t bb_node, loop_node;
-  loop_p loop;
 
   /* We can not use loop/bb node access macros because of potential
      checking and because the nodes are not initialized enough
      yet.  */
-  FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
-     if (ira_loop_nodes[i].regno_allocno_map != NULL)
-       {
-        ira_loop_nodes[i].children = NULL;
-        ira_loop_nodes[i].subloops = NULL;
-       }
   FOR_EACH_BB (bb)
     {
       bb_node = &ira_bb_nodes[bb->index];
@@ -324,18 +343,23 @@ form_loop_tree (void)
       bb_node->children = NULL;
       bb_node->subloop_next = NULL;
       bb_node->next = NULL;
-      for (parent = bb->loop_father;
-          parent != NULL;
-          parent = loop_outer (parent))
-       if (ira_loop_nodes[parent->num].regno_allocno_map != NULL)
-         break;
+      if (current_loops == NULL)
+       parent = NULL;
+      else
+       {
+         for (parent = bb->loop_father;
+              parent != NULL;
+              parent = loop_outer (parent))
+           if (ira_loop_nodes[parent->num].regno_allocno_map != NULL)
+             break;
+       }
       add_loop_to_tree (parent);
-      loop_node = &ira_loop_nodes[parent->num];
+      loop_node = &ira_loop_nodes[parent == NULL ? 0 : parent->num];
       bb_node->next = loop_node->children;
       bb_node->parent = loop_node;
       loop_node->children = bb_node;
     }
-  ira_loop_tree_root = IRA_LOOP_NODE_BY_INDEX (ira_loops.tree_root->num);
+  ira_loop_tree_root = IRA_LOOP_NODE_BY_INDEX (0);
   ira_loop_tree_height = setup_loop_tree_level (ira_loop_tree_root, 0);
   ira_assert (ira_loop_tree_root->regno_allocno_map != NULL);
 }
@@ -354,6 +378,7 @@ rebuild_regno_allocno_maps (void)
   loop_p loop;
   ira_allocno_iterator ai;
 
+  ira_assert (current_loops != NULL);
   max_regno = max_reg_num ();
   FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, l, loop)
     if (ira_loop_nodes[l].regno_allocno_map != NULL)
@@ -416,7 +441,8 @@ initiate_allocnos (void)
     = VEC_alloc (ira_object_t, heap, max_reg_num () * 2);
   ira_object_id_map = NULL;
   ira_regno_allocno_map
-    = (ira_allocno_t *) ira_allocate (max_reg_num () * sizeof (ira_allocno_t));
+    = (ira_allocno_t *) ira_allocate (max_reg_num ()
+                                     * sizeof (ira_allocno_t));
   memset (ira_regno_allocno_map, 0, max_reg_num () * sizeof (ira_allocno_t));
 }
 
@@ -424,7 +450,7 @@ initiate_allocnos (void)
 static ira_object_t
 ira_create_object (ira_allocno_t a, int subword)
 {
-  enum reg_class cover_class = ALLOCNO_COVER_CLASS (a);
+  enum reg_class aclass = ALLOCNO_CLASS (a);
   ira_object_t obj = (ira_object_t) pool_alloc (object_pool);
 
   OBJECT_ALLOCNO (obj) = a;
@@ -436,9 +462,9 @@ ira_create_object (ira_allocno_t a, int subword)
   COPY_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), ira_no_alloc_regs);
   COPY_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), ira_no_alloc_regs);
   IOR_COMPL_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
-                         reg_class_contents[cover_class]);
+                         reg_class_contents[aclass]);
   IOR_COMPL_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
-                         reg_class_contents[cover_class]);
+                         reg_class_contents[aclass]);
   OBJECT_MIN (obj) = INT_MAX;
   OBJECT_MAX (obj) = -1;
   OBJECT_LIVE_RANGES (obj) = NULL;
@@ -455,7 +481,8 @@ ira_create_object (ira_allocno_t a, int subword)
    LOOP_TREE_NODE.  Add the allocno to the list of allocnos with the
    same regno if CAP_P is FALSE.  */
 ira_allocno_t
-ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node)
+ira_create_allocno (int regno, bool cap_p,
+                   ira_loop_tree_node_t loop_tree_node)
 {
   ira_allocno_t a;
 
@@ -485,35 +512,24 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node)
   ALLOCNO_NO_STACK_REG_P (a) = false;
   ALLOCNO_TOTAL_NO_STACK_REG_P (a) = false;
 #endif
-  ALLOCNO_MEM_OPTIMIZED_DEST (a) = NULL;
-  ALLOCNO_MEM_OPTIMIZED_DEST_P (a) = false;
-  ALLOCNO_SOMEWHERE_RENAMED_P (a) = false;
-  ALLOCNO_CHILD_RENAMED_P (a) = false;
   ALLOCNO_DONT_REASSIGN_P (a) = false;
   ALLOCNO_BAD_SPILL_P (a) = false;
-  ALLOCNO_IN_GRAPH_P (a) = false;
   ALLOCNO_ASSIGNED_P (a) = false;
-  ALLOCNO_MAY_BE_SPILLED_P (a) = false;
-  ALLOCNO_SPLAY_REMOVED_P (a) = false;
   ALLOCNO_MODE (a) = (regno < 0 ? VOIDmode : PSEUDO_REGNO_MODE (regno));
   ALLOCNO_COPIES (a) = NULL;
   ALLOCNO_HARD_REG_COSTS (a) = NULL;
   ALLOCNO_CONFLICT_HARD_REG_COSTS (a) = NULL;
   ALLOCNO_UPDATED_HARD_REG_COSTS (a) = NULL;
   ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a) = NULL;
-  ALLOCNO_LEFT_CONFLICTS_SIZE (a) = -1;
-  ALLOCNO_COVER_CLASS (a) = NO_REGS;
-  ALLOCNO_UPDATED_COVER_CLASS_COST (a) = 0;
-  ALLOCNO_COVER_CLASS_COST (a) = 0;
+  ALLOCNO_CLASS (a) = NO_REGS;
+  ALLOCNO_UPDATED_CLASS_COST (a) = 0;
+  ALLOCNO_CLASS_COST (a) = 0;
   ALLOCNO_MEMORY_COST (a) = 0;
   ALLOCNO_UPDATED_MEMORY_COST (a) = 0;
   ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (a) = 0;
-  ALLOCNO_NEXT_BUCKET_ALLOCNO (a) = NULL;
-  ALLOCNO_PREV_BUCKET_ALLOCNO (a) = NULL;
-  ALLOCNO_FIRST_COALESCED_ALLOCNO (a) = a;
-  ALLOCNO_NEXT_COALESCED_ALLOCNO (a) = a;
   ALLOCNO_NUM_OBJECTS (a) = 0;
 
+  ALLOCNO_ADD_DATA (a) = NULL;
   VEC_safe_push (ira_allocno_t, heap, allocno_vec, a);
   ira_allocnos = VEC_address (ira_allocno_t, allocno_vec);
   ira_allocnos_num = VEC_length (ira_allocno_t, allocno_vec);
@@ -521,11 +537,22 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node)
   return a;
 }
 
-/* Set up cover class for A and update its conflict hard registers.  */
+/* Set up register class for A and update its conflict hard
+   registers.  */
 void
-ira_set_allocno_cover_class (ira_allocno_t a, enum reg_class cover_class)
+ira_set_allocno_class (ira_allocno_t a, enum reg_class aclass)
 {
-  ALLOCNO_COVER_CLASS (a) = cover_class;
+  ira_allocno_object_iterator oi;
+  ira_object_t obj;
+
+  ALLOCNO_CLASS (a) = aclass;
+  FOR_EACH_ALLOCNO_OBJECT (a, obj, oi)
+    {
+      IOR_COMPL_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
+                             reg_class_contents[aclass]);
+      IOR_COMPL_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
+                             reg_class_contents[aclass]);
+    }
 }
 
 /* Determine the number of objects we should associate with allocno A
@@ -534,8 +561,8 @@ void
 ira_create_allocno_objects (ira_allocno_t a)
 {
   enum machine_mode mode = ALLOCNO_MODE (a);
-  enum reg_class cover_class = ALLOCNO_COVER_CLASS (a);
-  int n = ira_reg_class_nregs[cover_class][mode];
+  enum reg_class aclass = ALLOCNO_CLASS (a);
+  int n = ira_reg_class_max_nregs[aclass][mode];
   int i;
 
   if (GET_MODE_SIZE (mode) != 2 * UNITS_PER_WORD || n != 2)
@@ -547,7 +574,7 @@ ira_create_allocno_objects (ira_allocno_t a)
 }
 
 /* For each allocno, set ALLOCNO_NUM_OBJECTS and create the
-   ALLOCNO_OBJECT structures.  This must be called after the cover
+   ALLOCNO_OBJECT structures.  This must be called after the allocno
    classes are known.  */
 static void
 create_allocno_objects (void)
@@ -572,6 +599,7 @@ merge_hard_reg_conflicts (ira_allocno_t from, ira_allocno_t to,
     {
       ira_object_t from_obj = ALLOCNO_OBJECT (from, i);
       ira_object_t to_obj = ALLOCNO_OBJECT (to, i);
+
       if (!total_only)
        IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (to_obj),
                          OBJECT_CONFLICT_HARD_REGS (from_obj));
@@ -593,6 +621,7 @@ ior_hard_reg_conflicts (ira_allocno_t a, HARD_REG_SET *set)
 {
   ira_allocno_object_iterator i;
   ira_object_t obj;
+
   FOR_EACH_ALLOCNO_OBJECT (a, obj, i)
     {
       IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), *set);
@@ -834,7 +863,7 @@ ira_print_expanded_allocno (ira_allocno_t a)
   if ((bb = ALLOCNO_LOOP_TREE_NODE (a)->bb) != NULL)
     fprintf (ira_dump_file, ",b%d", bb->index);
   else
-    fprintf (ira_dump_file, ",l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop->num);
+    fprintf (ira_dump_file, ",l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop_num);
   if (ALLOCNO_CAP_MEMBER (a) != NULL)
     {
       fprintf (ira_dump_file, ":");
@@ -850,25 +879,22 @@ create_cap_allocno (ira_allocno_t a)
 {
   ira_allocno_t cap;
   ira_loop_tree_node_t parent;
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
-  ira_assert (ALLOCNO_FIRST_COALESCED_ALLOCNO (a) == a
-             && ALLOCNO_NEXT_COALESCED_ALLOCNO (a) == a);
   parent = ALLOCNO_LOOP_TREE_NODE (a)->parent;
   cap = ira_create_allocno (ALLOCNO_REGNO (a), true, parent);
   ALLOCNO_MODE (cap) = ALLOCNO_MODE (a);
-  cover_class = ALLOCNO_COVER_CLASS (a);
-  ira_set_allocno_cover_class (cap, cover_class);
+  aclass = ALLOCNO_CLASS (a);
+  ira_set_allocno_class (cap, aclass);
   ira_create_allocno_objects (cap);
-  ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a);
   ALLOCNO_CAP_MEMBER (cap) = a;
   ALLOCNO_CAP (a) = cap;
-  ALLOCNO_COVER_CLASS_COST (cap) = ALLOCNO_COVER_CLASS_COST (a);
+  ALLOCNO_CLASS_COST (cap) = ALLOCNO_CLASS_COST (a);
   ALLOCNO_MEMORY_COST (cap) = ALLOCNO_MEMORY_COST (a);
   ira_allocate_and_copy_costs
-    (&ALLOCNO_HARD_REG_COSTS (cap), cover_class, ALLOCNO_HARD_REG_COSTS (a));
+    (&ALLOCNO_HARD_REG_COSTS (cap), aclass, ALLOCNO_HARD_REG_COSTS (a));
   ira_allocate_and_copy_costs
-    (&ALLOCNO_CONFLICT_HARD_REG_COSTS (cap), cover_class,
+    (&ALLOCNO_CONFLICT_HARD_REG_COSTS (cap), aclass,
      ALLOCNO_CONFLICT_HARD_REG_COSTS (a));
   ALLOCNO_BAD_SPILL_P (cap) = ALLOCNO_BAD_SPILL_P (a);
   ALLOCNO_NREFS (cap) = ALLOCNO_NREFS (a);
@@ -1064,23 +1090,24 @@ ira_finish_live_range_list (live_range_t r)
 void
 ira_free_allocno_updated_costs (ira_allocno_t a)
 {
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
-  cover_class = ALLOCNO_COVER_CLASS (a);
+  aclass = ALLOCNO_CLASS (a);
   if (ALLOCNO_UPDATED_HARD_REG_COSTS (a) != NULL)
-    ira_free_cost_vector (ALLOCNO_UPDATED_HARD_REG_COSTS (a), cover_class);
+    ira_free_cost_vector (ALLOCNO_UPDATED_HARD_REG_COSTS (a), aclass);
   ALLOCNO_UPDATED_HARD_REG_COSTS (a) = NULL;
   if (ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a) != NULL)
     ira_free_cost_vector (ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a),
-                         cover_class);
+                         aclass);
   ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a) = NULL;
 }
 
-/* Free the memory allocated for allocno A.  */
+/* Free and nullify all cost vectors allocated earlier for allocno
+   A.  */
 static void
-finish_allocno (ira_allocno_t a)
+ira_free_allocno_costs (ira_allocno_t a)
 {
-  enum reg_class cover_class = ALLOCNO_COVER_CLASS (a);
+  enum reg_class aclass = ALLOCNO_CLASS (a);
   ira_object_t obj;
   ira_allocno_object_iterator oi;
 
@@ -1095,14 +1122,25 @@ finish_allocno (ira_allocno_t a)
 
   ira_allocnos[ALLOCNO_NUM (a)] = NULL;
   if (ALLOCNO_HARD_REG_COSTS (a) != NULL)
-    ira_free_cost_vector (ALLOCNO_HARD_REG_COSTS (a), cover_class);
+    ira_free_cost_vector (ALLOCNO_HARD_REG_COSTS (a), aclass);
   if (ALLOCNO_CONFLICT_HARD_REG_COSTS (a) != NULL)
-    ira_free_cost_vector (ALLOCNO_CONFLICT_HARD_REG_COSTS (a), cover_class);
+    ira_free_cost_vector (ALLOCNO_CONFLICT_HARD_REG_COSTS (a), aclass);
   if (ALLOCNO_UPDATED_HARD_REG_COSTS (a) != NULL)
-    ira_free_cost_vector (ALLOCNO_UPDATED_HARD_REG_COSTS (a), cover_class);
+    ira_free_cost_vector (ALLOCNO_UPDATED_HARD_REG_COSTS (a), aclass);
   if (ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a) != NULL)
     ira_free_cost_vector (ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a),
-                         cover_class);
+                         aclass);
+  ALLOCNO_HARD_REG_COSTS (a) = NULL;
+  ALLOCNO_CONFLICT_HARD_REG_COSTS (a) = NULL;
+  ALLOCNO_UPDATED_HARD_REG_COSTS (a) = NULL;
+  ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (a) = NULL;
+}
+
+/* Free the memory allocated for allocno A.  */
+static void
+finish_allocno (ira_allocno_t a)
+{
+  ira_free_allocno_costs (a);
   pool_free (allocno_pool, a);
 }
 
@@ -1366,55 +1404,54 @@ finish_copies (void)
 
 \f
 
-/* Pools for cost vectors.  It is defined only for cover classes.  */
+/* Pools for cost vectors.  It is defined only for allocno classes.  */
 static alloc_pool cost_vector_pool[N_REG_CLASSES];
 
 /* The function initiates work with hard register cost vectors.  It
-   creates allocation pool for each cover class.  */
+   creates allocation pool for each allocno class.  */
 static void
 initiate_cost_vectors (void)
 {
   int i;
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
-  for (i = 0; i < ira_reg_class_cover_size; i++)
+  for (i = 0; i < ira_allocno_classes_num; i++)
     {
-      cover_class = ira_reg_class_cover[i];
-      cost_vector_pool[cover_class]
+      aclass = ira_allocno_classes[i];
+      cost_vector_pool[aclass]
        = create_alloc_pool ("cost vectors",
-                            sizeof (int)
-                            * ira_class_hard_regs_num[cover_class],
+                            sizeof (int) * ira_class_hard_regs_num[aclass],
                             100);
     }
 }
 
-/* Allocate and return a cost vector VEC for COVER_CLASS.  */
+/* Allocate and return a cost vector VEC for ACLASS.  */
 int *
-ira_allocate_cost_vector (enum reg_class cover_class)
+ira_allocate_cost_vector (reg_class_t aclass)
 {
-  return (int *) pool_alloc (cost_vector_pool[cover_class]);
+  return (int *) pool_alloc (cost_vector_pool[(int) aclass]);
 }
 
-/* Free a cost vector VEC for COVER_CLASS.  */
+/* Free a cost vector VEC for ACLASS.  */
 void
-ira_free_cost_vector (int *vec, enum reg_class cover_class)
+ira_free_cost_vector (int *vec, reg_class_t aclass)
 {
   ira_assert (vec != NULL);
-  pool_free (cost_vector_pool[cover_class], vec);
+  pool_free (cost_vector_pool[(int) aclass], vec);
 }
 
 /* Finish work with hard register cost vectors.  Release allocation
-   pool for each cover class.  */
+   pool for each allocno class.  */
 static void
 finish_cost_vectors (void)
 {
   int i;
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
-  for (i = 0; i < ira_reg_class_cover_size; i++)
+  for (i = 0; i < ira_allocno_classes_num; i++)
     {
-      cover_class = ira_reg_class_cover[i];
-      free_alloc_pool (cost_vector_pool[cover_class]);
+      aclass = ira_allocno_classes[i];
+      free_alloc_pool (cost_vector_pool[aclass]);
     }
 }
 
@@ -1610,6 +1647,7 @@ create_loop_tree_node_allocnos (ira_loop_tree_node_t loop_node)
       edge e;
       VEC (edge, heap) *edges;
 
+      ira_assert (current_loops != NULL);
       FOR_EACH_EDGE (e, ei, loop_node->loop->header->preds)
        if (e->src != loop_node->loop->latch)
          create_loop_allocnos (e);
@@ -1645,7 +1683,7 @@ propagate_allocno_info (void)
   int i;
   ira_allocno_t a, parent_a;
   ira_loop_tree_node_t parent;
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
   if (flag_ira_region != IRA_REGION_ALL
       && flag_ira_region != IRA_REGION_MIXED)
@@ -1671,17 +1709,17 @@ propagate_allocno_info (void)
            += ALLOCNO_CALLS_CROSSED_NUM (a);
          ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (parent_a)
            += ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (a);
-         cover_class = ALLOCNO_COVER_CLASS (a);
-         ira_assert (cover_class == ALLOCNO_COVER_CLASS (parent_a));
+         aclass = ALLOCNO_CLASS (a);
+         ira_assert (aclass == ALLOCNO_CLASS (parent_a));
          ira_allocate_and_accumulate_costs
-           (&ALLOCNO_HARD_REG_COSTS (parent_a), cover_class,
+           (&ALLOCNO_HARD_REG_COSTS (parent_a), aclass,
             ALLOCNO_HARD_REG_COSTS (a));
          ira_allocate_and_accumulate_costs
            (&ALLOCNO_CONFLICT_HARD_REG_COSTS (parent_a),
-            cover_class,
+            aclass,
             ALLOCNO_CONFLICT_HARD_REG_COSTS (a));
-         ALLOCNO_COVER_CLASS_COST (parent_a)
-           += ALLOCNO_COVER_CLASS_COST (a);
+         ALLOCNO_CLASS_COST (parent_a)
+           += ALLOCNO_CLASS_COST (a);
          ALLOCNO_MEMORY_COST (parent_a) += ALLOCNO_MEMORY_COST (a);
        }
 }
@@ -1779,21 +1817,50 @@ static bool
 low_pressure_loop_node_p (ira_loop_tree_node_t node)
 {
   int i;
-  enum reg_class cover_class;
+  enum reg_class pclass;
 
   if (node->bb != NULL)
     return false;
 
-  for (i = 0; i < ira_reg_class_cover_size; i++)
+  for (i = 0; i < ira_pressure_classes_num; i++)
     {
-      cover_class = ira_reg_class_cover[i];
-      if (node->reg_pressure[cover_class]
-         > ira_available_class_regs[cover_class])
+      pclass = ira_pressure_classes[i];
+      if (node->reg_pressure[pclass] > ira_available_class_regs[pclass]
+         && ira_available_class_regs[pclass] > 1)
        return false;
     }
   return true;
 }
 
+#ifdef STACK_REGS
+/* Return TRUE if LOOP has a complex enter or exit edge.  We don't
+   form a region from such loop if the target use stack register
+   because reg-stack.c can not deal with such edges.  */
+static bool
+loop_with_complex_edge_p (struct loop *loop)
+{
+  int i;
+  edge_iterator ei;
+  edge e;
+  VEC (edge, heap) *edges;
+  bool res;
+
+  FOR_EACH_EDGE (e, ei, loop->header->preds)
+    if (e->flags & EDGE_EH)
+      return true;
+  edges = get_loop_exit_edges (loop);
+  res = false;
+  FOR_EACH_VEC_ELT (edge, edges, i, e)
+    if (e->flags & EDGE_COMPLEX)
+      {
+       res = true;
+       break;
+      }
+  VEC_free (edge, heap, edges);
+  return res;
+}
+#endif
+
 /* Sort loops for marking them for removal.  We put already marked
    loops first, then less frequent loops next, and then outer loops
    next.  */
@@ -1814,17 +1881,21 @@ loop_compare_func (const void *v1p, const void *v2p)
   if ((diff = (int) loop_depth (l1->loop) - (int) loop_depth (l2->loop)) != 0)
     return diff;
   /* Make sorting stable.  */
-  return l1->loop->num - l2->loop->num;
+  return l1->loop_num - l2->loop_num;
 }
 
-
 /* Mark loops which should be removed from regional allocation.  We
    remove a loop with low register pressure inside another loop with
    register pressure.  In this case a separate allocation of the loop
    hardly helps (for irregular register file architecture it could
    help by choosing a better hard register in the loop but we prefer
    faster allocation even in this case).  We also remove cheap loops
-   if there are more than IRA_MAX_LOOPS_NUM of them.  */
+   if there are more than IRA_MAX_LOOPS_NUM of them.  Loop with EH
+   exit or enter edges are removed too because the allocation might
+   require put pseudo moves on the EH edges (we could still do this
+   for pseudos with caller saved hard registers in some cases but it
+   is impossible to say here or during top-down allocation pass what
+   hard register the pseudos get finally).  */
 static void
 mark_loops_for_removal (void)
 {
@@ -1832,6 +1903,7 @@ mark_loops_for_removal (void)
   ira_loop_tree_node_t *sorted_loops;
   loop_p loop;
 
+  ira_assert (current_loops != NULL);
   sorted_loops
     = (ira_loop_tree_node_t *) ira_allocate (sizeof (ira_loop_tree_node_t)
                                             * VEC_length (loop_p,
@@ -1847,8 +1919,12 @@ mark_loops_for_removal (void)
          }
        sorted_loops[n++] = &ira_loop_nodes[i];
        ira_loop_nodes[i].to_remove_p
-         = (low_pressure_loop_node_p (ira_loop_nodes[i].parent)
-            && low_pressure_loop_node_p (&ira_loop_nodes[i]));
+         = ((low_pressure_loop_node_p (ira_loop_nodes[i].parent)
+             && low_pressure_loop_node_p (&ira_loop_nodes[i]))
+#ifdef STACK_REGS
+            || loop_with_complex_edge_p (ira_loop_nodes[i].loop)
+#endif
+            );
       }
   qsort (sorted_loops, n, sizeof (ira_loop_tree_node_t), loop_compare_func);
   for (i = 0; n - i + 1 > IRA_MAX_LOOPS_NUM; i++)
@@ -1858,7 +1934,7 @@ mark_loops_for_removal (void)
        fprintf
          (ira_dump_file,
           "  Mark loop %d (header %d, freq %d, depth %d) for removal (%s)\n",
-          sorted_loops[i]->loop->num, sorted_loops[i]->loop->header->index,
+          sorted_loops[i]->loop_num, sorted_loops[i]->loop->header->index,
           sorted_loops[i]->loop->header->frequency,
           loop_depth (sorted_loops[i]->loop),
           low_pressure_loop_node_p (sorted_loops[i]->parent)
@@ -1875,6 +1951,7 @@ mark_all_loops_for_removal (void)
   int i;
   loop_p loop;
 
+  ira_assert (current_loops != NULL);
   FOR_EACH_VEC_ELT (loop_p, ira_loops.larray, i, loop)
     if (ira_loop_nodes[i].regno_allocno_map != NULL)
       {
@@ -1889,7 +1966,7 @@ mark_all_loops_for_removal (void)
          fprintf
            (ira_dump_file,
             "  Mark loop %d (header %d, freq %d, depth %d) for removal\n",
-            ira_loop_nodes[i].loop->num,
+            ira_loop_nodes[i].loop_num,
             ira_loop_nodes[i].loop->header->index,
             ira_loop_nodes[i].loop->header->frequency,
             loop_depth (ira_loop_nodes[i].loop));
@@ -2004,7 +2081,7 @@ ira_rebuild_regno_allocno_list (int regno)
 static void
 propagate_some_info_from_allocno (ira_allocno_t a, ira_allocno_t from_a)
 {
-  enum reg_class cover_class;
+  enum reg_class aclass;
 
   merge_hard_reg_conflicts (from_a, a, false);
   ALLOCNO_NREFS (a) += ALLOCNO_NREFS (from_a);
@@ -2015,14 +2092,14 @@ propagate_some_info_from_allocno (ira_allocno_t a, ira_allocno_t from_a)
     += ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (from_a);
   if (! ALLOCNO_BAD_SPILL_P (from_a))
     ALLOCNO_BAD_SPILL_P (a) = false;
-  cover_class = ALLOCNO_COVER_CLASS (from_a);
-  ira_assert (cover_class == ALLOCNO_COVER_CLASS (a));
-  ira_allocate_and_accumulate_costs (&ALLOCNO_HARD_REG_COSTS (a), cover_class,
+  aclass = ALLOCNO_CLASS (from_a);
+  ira_assert (aclass == ALLOCNO_CLASS (a));
+  ira_allocate_and_accumulate_costs (&ALLOCNO_HARD_REG_COSTS (a), aclass,
                                     ALLOCNO_HARD_REG_COSTS (from_a));
   ira_allocate_and_accumulate_costs (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a),
-                                    cover_class,
+                                    aclass,
                                     ALLOCNO_CONFLICT_HARD_REG_COSTS (from_a));
-  ALLOCNO_COVER_CLASS_COST (a) += ALLOCNO_COVER_CLASS_COST (from_a);
+  ALLOCNO_CLASS_COST (a) += ALLOCNO_CLASS_COST (from_a);
   ALLOCNO_MEMORY_COST (a) += ALLOCNO_MEMORY_COST (from_a);
 }
 
@@ -2174,11 +2251,13 @@ remove_low_level_allocnos (void)
 /* Remove loops from consideration.  We remove all loops except for
    root if ALL_P or loops for which a separate allocation will not
    improve the result.  We have to do this after allocno creation and
-   their costs and cover class evaluation because only after that the
-   register pressure can be known and is calculated.  */
+   their costs and allocno class evaluation because only after that
+   the register pressure can be known and is calculated.  */
 static void
 remove_unnecessary_regions (bool all_p)
 {
+  if (current_loops == NULL)
+    return;
   if (all_p)
     mark_all_loops_for_removal ();
   else
@@ -2224,27 +2303,27 @@ update_bad_spill_attribute (void)
   ira_allocno_object_iterator aoi;
   ira_object_t obj;
   live_range_t r;
-  enum reg_class cover_class;
+  enum reg_class aclass;
   bitmap_head dead_points[N_REG_CLASSES];
 
-  for (i = 0; i < ira_reg_class_cover_size; i++)
+  for (i = 0; i < ira_allocno_classes_num; i++)
     {
-      cover_class = ira_reg_class_cover[i];
-      bitmap_initialize (&dead_points[cover_class], &reg_obstack);
+      aclass = ira_allocno_classes[i];
+      bitmap_initialize (&dead_points[aclass], &reg_obstack);
     }
   FOR_EACH_ALLOCNO (a, ai)
     {
-      cover_class = ALLOCNO_COVER_CLASS (a);
-      if (cover_class == NO_REGS)
+      aclass = ALLOCNO_CLASS (a);
+      if (aclass == NO_REGS)
        continue;
       FOR_EACH_ALLOCNO_OBJECT (a, obj, aoi)
        for (r = OBJECT_LIVE_RANGES (obj); r != NULL; r = r->next)
-         bitmap_set_bit (&dead_points[cover_class], r->finish);
+         bitmap_set_bit (&dead_points[aclass], r->finish);
     }
   FOR_EACH_ALLOCNO (a, ai)
     {
-      cover_class = ALLOCNO_COVER_CLASS (a);
-      if (cover_class == NO_REGS)
+      aclass = ALLOCNO_CLASS (a);
+      if (aclass == NO_REGS)
        continue;
       if (! ALLOCNO_BAD_SPILL_P (a))
        continue;
@@ -2253,7 +2332,7 @@ update_bad_spill_attribute (void)
          for (r = OBJECT_LIVE_RANGES (obj); r != NULL; r = r->next)
            {
              for (i = r->start + 1; i < r->finish; i++)
-               if (bitmap_bit_p (&dead_points[cover_class], i))
+               if (bitmap_bit_p (&dead_points[aclass], i))
                  break;
              if (i < r->finish)
                break;
@@ -2265,10 +2344,10 @@ update_bad_spill_attribute (void)
            }
        }
     }
-  for (i = 0; i < ira_reg_class_cover_size; i++)
+  for (i = 0; i < ira_allocno_classes_num; i++)
     {
-      cover_class = ira_reg_class_cover[i];
-      bitmap_clear (&dead_points[cover_class]);
+      aclass = ira_allocno_classes[i];
+      bitmap_clear (&dead_points[aclass]);
     }
 }
 
@@ -2291,6 +2370,7 @@ setup_min_max_allocno_live_range_point (void)
   FOR_EACH_ALLOCNO (a, ai)
     {
       int n = ALLOCNO_NUM_OBJECTS (a);
+
       for (i = 0; i < n; i++)
        {
          ira_object_t obj = ALLOCNO_OBJECT (a, i);
@@ -2310,6 +2390,7 @@ setup_min_max_allocno_live_range_point (void)
       {
        int j;
        int n = ALLOCNO_NUM_OBJECTS (a);
+
        for (j = 0; j < n; j++)
          {
            ira_object_t obj = ALLOCNO_OBJECT (a, j);
@@ -2353,10 +2434,10 @@ setup_min_max_allocno_live_range_point (void)
 }
 
 /* Sort allocnos according to their live ranges.  Allocnos with
-   smaller cover class are put first unless we use priority coloring.
-   Allocnos with the same cover class are ordered according their start
-   (min).  Allocnos with the same start are ordered according their
-   finish (max).  */
+   smaller allocno class are put first unless we use priority
+   coloring.  Allocnos with the same class are ordered according
+   their start (min).  Allocnos with the same start are ordered
+   according their finish (max).  */
 static int
 object_range_compare_func (const void *v1p, const void *v2p)
 {
@@ -2366,9 +2447,6 @@ object_range_compare_func (const void *v1p, const void *v2p)
   ira_allocno_t a1 = OBJECT_ALLOCNO (obj1);
   ira_allocno_t a2 = OBJECT_ALLOCNO (obj2);
 
-  if (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY
-      && (diff = ALLOCNO_COVER_CLASS (a1) - ALLOCNO_COVER_CLASS (a2)) != 0)
-    return diff;
   if ((diff = OBJECT_MIN (obj1) - OBJECT_MIN (obj2)) != 0)
     return diff;
   if ((diff = OBJECT_MAX (obj1) - OBJECT_MAX (obj2)) != 0)
@@ -2398,6 +2476,7 @@ sort_conflict_id_map (void)
   for (i = 0; i < num; i++)
     {
       ira_object_t obj = ira_object_id_map[i];
+
       gcc_assert (obj != NULL);
       OBJECT_CONFLICT_ID (obj) = i;
     }
@@ -2410,7 +2489,7 @@ sort_conflict_id_map (void)
 static void
 setup_min_max_conflict_allocno_ids (void)
 {
-  int cover_class;
+  int aclass;
   int i, j, min, max, start, finish, first_not_finished, filled_area_start;
   int *live_range_min, *last_lived;
   int word0_min, word0_max;
@@ -2418,21 +2497,20 @@ setup_min_max_conflict_allocno_ids (void)
   ira_allocno_iterator ai;
 
   live_range_min = (int *) ira_allocate (sizeof (int) * ira_objects_num);
-  cover_class = -1;
+  aclass = -1;
   first_not_finished = -1;
   for (i = 0; i < ira_objects_num; i++)
     {
       ira_object_t obj = ira_object_id_map[i];
+
       if (obj == NULL)
        continue;
 
       a = OBJECT_ALLOCNO (obj);
 
-      if (cover_class < 0
-         || (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY
-             && cover_class != (int) ALLOCNO_COVER_CLASS (a)))
+      if (aclass < 0)
        {
-         cover_class = ALLOCNO_COVER_CLASS (a);
+         aclass = ALLOCNO_CLASS (a);
          min = i;
          first_not_finished = i;
        }
@@ -2457,20 +2535,19 @@ setup_min_max_conflict_allocno_ids (void)
       OBJECT_MIN (obj) = min;
     }
   last_lived = (int *) ira_allocate (sizeof (int) * ira_max_point);
-  cover_class = -1;
+  aclass = -1;
   filled_area_start = -1;
   for (i = ira_objects_num - 1; i >= 0; i--)
     {
       ira_object_t obj = ira_object_id_map[i];
+
       if (obj == NULL)
        continue;
 
       a = OBJECT_ALLOCNO (obj);
-      if (cover_class < 0
-         || (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY
-             && cover_class != (int) ALLOCNO_COVER_CLASS (a)))
+      if (aclass < 0)
        {
-         cover_class = ALLOCNO_COVER_CLASS (a);
+         aclass = ALLOCNO_CLASS (a);
          for (j = 0; j < ira_max_point; j++)
            last_lived[j] = -1;
          filled_area_start = ira_max_point;
@@ -2508,6 +2585,7 @@ setup_min_max_conflict_allocno_ids (void)
     {
       int n = ALLOCNO_NUM_OBJECTS (a);
       ira_object_t obj0;
+
       if (n < 2)
        continue;
       obj0 = ALLOCNO_OBJECT (a, 0);
@@ -2520,6 +2598,7 @@ setup_min_max_conflict_allocno_ids (void)
     {
       int n = ALLOCNO_NUM_OBJECTS (a);
       ira_object_t obj0;
+
       if (n < 2)
        continue;
       obj0 = ALLOCNO_OBJECT (a, 0);
@@ -2612,7 +2691,7 @@ copy_info_to_removed_store_destinations (int regno)
        a != NULL;
        a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
     {
-      if (a != regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))])
+      if (a != regno_top_level_allocno_map[REGNO (allocno_emit_reg (a))])
        /* This allocno will be removed.  */
        continue;
 
@@ -2622,9 +2701,10 @@ copy_info_to_removed_store_destinations (int regno)
           parent != NULL;
           parent = parent->parent)
        if ((parent_a = parent->regno_allocno_map[regno]) == NULL
-           || (parent_a == regno_top_level_allocno_map[REGNO (ALLOCNO_REG
-                                                              (parent_a))]
-               && ALLOCNO_MEM_OPTIMIZED_DEST_P (parent_a)))
+           || (parent_a
+               == regno_top_level_allocno_map[REGNO
+                                              (allocno_emit_reg (parent_a))]
+               && ALLOCNO_EMIT_DATA (parent_a)->mem_optimized_dest_p))
          break;
       if (parent == NULL || parent_a == NULL)
        continue;
@@ -2656,7 +2736,7 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
   int hard_regs_num;
   bool new_pseudos_p, merged_p, mem_dest_p;
   unsigned int n;
-  enum reg_class cover_class;
+  enum reg_class aclass;
   ira_allocno_t a, parent_a, first, second, node_first, node_second;
   ira_copy_t cp;
   ira_loop_tree_node_t node;
@@ -2665,7 +2745,8 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
   ira_copy_iterator ci;
 
   regno_top_level_allocno_map
-    = (ira_allocno_t *) ira_allocate (max_reg_num () * sizeof (ira_allocno_t));
+    = (ira_allocno_t *) ira_allocate (max_reg_num ()
+                                     * sizeof (ira_allocno_t));
   memset (regno_top_level_allocno_map, 0,
          max_reg_num () * sizeof (ira_allocno_t));
   new_pseudos_p = merged_p = false;
@@ -2673,6 +2754,7 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
     {
       ira_allocno_object_iterator oi;
       ira_object_t obj;
+
       if (ALLOCNO_CAP_MEMBER (a) != NULL)
        /* Caps are not in the regno allocno maps and they are never
           will be transformed into allocnos existing after IR
@@ -2693,28 +2775,31 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
           a != NULL;
           a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
        {
+         ira_emit_data_t parent_data, data = ALLOCNO_EMIT_DATA (a);
+
          ira_assert (ALLOCNO_CAP_MEMBER (a) == NULL);
-         if (ALLOCNO_SOMEWHERE_RENAMED_P (a))
+         if (data->somewhere_renamed_p)
            new_pseudos_p = true;
          parent_a = ira_parent_allocno (a);
          if (parent_a == NULL)
            {
              ALLOCNO_COPIES (a) = NULL;
-             regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))] = a;
+             regno_top_level_allocno_map[REGNO (data->reg)] = a;
              continue;
            }
          ira_assert (ALLOCNO_CAP_MEMBER (parent_a) == NULL);
 
-         if (ALLOCNO_MEM_OPTIMIZED_DEST (a) != NULL)
+         if (data->mem_optimized_dest != NULL)
            mem_dest_p = true;
-         if (REGNO (ALLOCNO_REG (a)) == REGNO (ALLOCNO_REG (parent_a)))
+         parent_data = ALLOCNO_EMIT_DATA (parent_a);
+         if (REGNO (data->reg) == REGNO (parent_data->reg))
            {
              merge_hard_reg_conflicts (a, parent_a, true);
              move_allocno_live_ranges (a, parent_a);
              merged_p = true;
-             ALLOCNO_MEM_OPTIMIZED_DEST_P (parent_a)
-               = (ALLOCNO_MEM_OPTIMIZED_DEST_P (parent_a)
-                  || ALLOCNO_MEM_OPTIMIZED_DEST_P (a));
+             parent_data->mem_optimized_dest_p
+               = (parent_data->mem_optimized_dest_p
+                  || data->mem_optimized_dest_p);
              continue;
            }
          new_pseudos_p = true;
@@ -2730,8 +2815,8 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
              ira_assert (ALLOCNO_CALLS_CROSSED_NUM (parent_a) >= 0
                          && ALLOCNO_NREFS (parent_a) >= 0
                          && ALLOCNO_FREQ (parent_a) >= 0);
-             cover_class = ALLOCNO_COVER_CLASS (parent_a);
-             hard_regs_num = ira_class_hard_regs_num[cover_class];
+             aclass = ALLOCNO_CLASS (parent_a);
+             hard_regs_num = ira_class_hard_regs_num[aclass];
              if (ALLOCNO_HARD_REG_COSTS (a) != NULL
                  && ALLOCNO_HARD_REG_COSTS (parent_a) != NULL)
                for (j = 0; j < hard_regs_num; j++)
@@ -2742,15 +2827,15 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
                for (j = 0; j < hard_regs_num; j++)
                  ALLOCNO_CONFLICT_HARD_REG_COSTS (parent_a)[j]
                    -= ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[j];
-             ALLOCNO_COVER_CLASS_COST (parent_a)
-               -= ALLOCNO_COVER_CLASS_COST (a);
+             ALLOCNO_CLASS_COST (parent_a)
+               -= ALLOCNO_CLASS_COST (a);
              ALLOCNO_MEMORY_COST (parent_a) -= ALLOCNO_MEMORY_COST (a);
              parent_a = ira_parent_allocno (parent_a);
              if (parent_a == NULL)
                break;
            }
          ALLOCNO_COPIES (a) = NULL;
-         regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))] = a;
+         regno_top_level_allocno_map[REGNO (data->reg)] = a;
        }
       if (mem_dest_p && copy_info_to_removed_store_destinations (i))
        merged_p = true;
@@ -2767,7 +2852,8 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
        {
          ira_allocno_object_iterator oi;
          ira_object_t obj;
-         if (a != regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))]
+
+         if (a != regno_top_level_allocno_map[REGNO (allocno_emit_reg (a))]
              || ALLOCNO_CAP_MEMBER (a) != NULL)
            continue;
          FOR_EACH_ALLOCNO_OBJECT (a, obj, oi)
@@ -2783,19 +2869,21 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
          for (r = ira_start_point_ranges[i]; r != NULL; r = r->start_next)
            {
              ira_object_t obj = r->object;
+
              a = OBJECT_ALLOCNO (obj);
-             if (a != regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))]
+             if (a != regno_top_level_allocno_map[REGNO (allocno_emit_reg (a))]
                  || ALLOCNO_CAP_MEMBER (a) != NULL)
                continue;
 
-             cover_class = ALLOCNO_COVER_CLASS (a);
+             aclass = ALLOCNO_CLASS (a);
              sparseset_set_bit (objects_live, OBJECT_CONFLICT_ID (obj));
              EXECUTE_IF_SET_IN_SPARSESET (objects_live, n)
                {
                  ira_object_t live_obj = ira_object_id_map[n];
                  ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj);
-                 enum reg_class live_cover = ALLOCNO_COVER_CLASS (live_a);
-                 if (ira_reg_classes_intersect_p[cover_class][live_cover]
+                 enum reg_class live_aclass = ALLOCNO_CLASS (live_a);
+
+                 if (ira_reg_classes_intersect_p[aclass][live_aclass]
                      /* Don't set up conflict for the allocno with itself.  */
                      && live_a != a)
                    ira_add_conflict (obj, live_obj);
@@ -2819,14 +2907,18 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
            fprintf
              (ira_dump_file, "      Remove cp%d:%c%dr%d-%c%dr%d\n",
               cp->num, ALLOCNO_CAP_MEMBER (cp->first) != NULL ? 'c' : 'a',
-              ALLOCNO_NUM (cp->first), REGNO (ALLOCNO_REG (cp->first)),
+              ALLOCNO_NUM (cp->first),
+              REGNO (allocno_emit_reg (cp->first)),
               ALLOCNO_CAP_MEMBER (cp->second) != NULL ? 'c' : 'a',
-              ALLOCNO_NUM (cp->second), REGNO (ALLOCNO_REG (cp->second)));
+              ALLOCNO_NUM (cp->second),
+              REGNO (allocno_emit_reg (cp->second)));
          cp->loop_tree_node = NULL;
          continue;
        }
-      first = regno_top_level_allocno_map[REGNO (ALLOCNO_REG (cp->first))];
-      second = regno_top_level_allocno_map[REGNO (ALLOCNO_REG (cp->second))];
+      first
+       = regno_top_level_allocno_map[REGNO (allocno_emit_reg (cp->first))];
+      second
+       = regno_top_level_allocno_map[REGNO (allocno_emit_reg (cp->second))];
       node = cp->loop_tree_node;
       if (node == NULL)
        keep_p = true; /* It copy generated in ira-emit.c.  */
@@ -2836,10 +2928,10 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
             which we will have different pseudos.  */
          node_first = node->regno_allocno_map[ALLOCNO_REGNO (cp->first)];
          node_second = node->regno_allocno_map[ALLOCNO_REGNO (cp->second)];
-         keep_p = ((REGNO (ALLOCNO_REG (first))
-                    == REGNO (ALLOCNO_REG (node_first)))
-                    && (REGNO (ALLOCNO_REG (second))
-                        == REGNO (ALLOCNO_REG (node_second))));
+         keep_p = ((REGNO (allocno_emit_reg (first))
+                    == REGNO (allocno_emit_reg (node_first)))
+                    && (REGNO (allocno_emit_reg (second))
+                        == REGNO (allocno_emit_reg (node_second))));
        }
       if (keep_p)
        {
@@ -2853,28 +2945,29 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit)
          if (internal_flag_ira_verbose > 4 && ira_dump_file != NULL)
            fprintf (ira_dump_file, "      Remove cp%d:a%dr%d-a%dr%d\n",
                     cp->num, ALLOCNO_NUM (cp->first),
-                    REGNO (ALLOCNO_REG (cp->first)), ALLOCNO_NUM (cp->second),
-                    REGNO (ALLOCNO_REG (cp->second)));
+                    REGNO (allocno_emit_reg (cp->first)),
+                    ALLOCNO_NUM (cp->second),
+                    REGNO (allocno_emit_reg (cp->second)));
        }
     }
   /* Remove unnecessary allocnos on lower levels of the loop tree.  */
   FOR_EACH_ALLOCNO (a, ai)
     {
-      if (a != regno_top_level_allocno_map[REGNO (ALLOCNO_REG (a))]
+      if (a != regno_top_level_allocno_map[REGNO (allocno_emit_reg (a))]
          || ALLOCNO_CAP_MEMBER (a) != NULL)
        {
          if (internal_flag_ira_verbose > 4 && ira_dump_file != NULL)
            fprintf (ira_dump_file, "      Remove a%dr%d\n",
-                    ALLOCNO_NUM (a), REGNO (ALLOCNO_REG (a)));
+                    ALLOCNO_NUM (a), REGNO (allocno_emit_reg (a)));
          finish_allocno (a);
          continue;
        }
       ALLOCNO_LOOP_TREE_NODE (a) = ira_loop_tree_root;
-      ALLOCNO_REGNO (a) = REGNO (ALLOCNO_REG (a));
+      ALLOCNO_REGNO (a) = REGNO (allocno_emit_reg (a));
       ALLOCNO_CAP (a) = NULL;
       /* Restore updated costs for assignments from reload.  */
       ALLOCNO_UPDATED_MEMORY_COST (a) = ALLOCNO_MEMORY_COST (a);
-      ALLOCNO_UPDATED_COVER_CLASS_COST (a) = ALLOCNO_COVER_CLASS_COST (a);
+      ALLOCNO_UPDATED_CLASS_COST (a) = ALLOCNO_CLASS_COST (a);
       if (! ALLOCNO_ASSIGNED_P (a))
        ira_free_allocno_updated_costs (a);
       ira_assert (ALLOCNO_UPDATED_HARD_REG_COSTS (a) == NULL);
@@ -2943,50 +3036,47 @@ update_conflict_hard_reg_costs (void)
 
   FOR_EACH_ALLOCNO (a, ai)
     {
-      enum reg_class cover_class = ALLOCNO_COVER_CLASS (a);
-      enum reg_class pref = reg_preferred_class (ALLOCNO_REGNO (a));
+      reg_class_t aclass = ALLOCNO_CLASS (a);
+      reg_class_t pref = reg_preferred_class (ALLOCNO_REGNO (a));
 
-      if (reg_class_size[pref] != 1)
+      if (reg_class_size[(int) pref] != 1)
        continue;
-      index = (ira_class_hard_reg_index[cover_class]
-              [ira_class_hard_regs[pref][0]]);
+      index = ira_class_hard_reg_index[(int) aclass]
+                                     [ira_class_hard_regs[(int) pref][0]];
       if (index < 0)
        continue;
       if (ALLOCNO_CONFLICT_HARD_REG_COSTS (a) == NULL
          || ALLOCNO_HARD_REG_COSTS (a) == NULL)
        continue;
       min = INT_MAX;
-      for (i = ira_class_hard_regs_num[cover_class] - 1; i >= 0; i--)
-       if (ALLOCNO_HARD_REG_COSTS (a)[i] > ALLOCNO_COVER_CLASS_COST (a)
+      for (i = ira_class_hard_regs_num[(int) aclass] - 1; i >= 0; i--)
+       if (ALLOCNO_HARD_REG_COSTS (a)[i] > ALLOCNO_CLASS_COST (a)
            && min > ALLOCNO_HARD_REG_COSTS (a)[i])
          min = ALLOCNO_HARD_REG_COSTS (a)[i];
       if (min == INT_MAX)
        continue;
       ira_allocate_and_set_costs (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a),
-                                 cover_class, 0);
+                                 aclass, 0);
       ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index]
-       -= min - ALLOCNO_COVER_CLASS_COST (a);
+       -= min - ALLOCNO_CLASS_COST (a);
     }
 }
 
 /* Create a internal representation (IR) for IRA (allocnos, copies,
-   loop tree nodes).  If LOOPS_P is FALSE the nodes corresponding to
-   the loops (except the root which corresponds the all function) and
-   correspondingly allocnos for the loops will be not created.  Such
-   parameter value is used for Chaitin-Briggs coloring.  The function
-   returns TRUE if we generate loop structure (besides nodes
-   representing all function and the basic blocks) for regional
-   allocation.  A true return means that we really need to flatten IR
-   before the reload.  */
+   loop tree nodes).  The function returns TRUE if we generate loop
+   structure (besides nodes representing all function and the basic
+   blocks) for regional allocation.  A true return means that we
+   really need to flatten IR before the reload.  */
 bool
-ira_build (bool loops_p)
+ira_build (void)
 {
-  df_analyze ();
+  bool loops_p;
 
+  df_analyze ();
   initiate_cost_vectors ();
   initiate_allocnos ();
   initiate_copies ();
-  create_loop_tree_nodes (loops_p);
+  create_loop_tree_nodes ();
   form_loop_tree ();
   create_allocnos ();
   ira_costs ();
@@ -3001,7 +3091,7 @@ ira_build (bool loops_p)
       propagate_allocno_info ();
       create_caps ();
     }
-  ira_tune_allocno_costs_and_cover_classes ();
+  ira_tune_allocno_costs ();
 #ifdef ENABLE_IRA_CHECKING
   check_allocno_creation ();
 #endif
@@ -3043,6 +3133,7 @@ ira_build (bool loops_p)
       FOR_EACH_ALLOCNO (a, ai)
        {
          int j, nobj = ALLOCNO_NUM_OBJECTS (a);
+
          if (nobj > 1)
            nr_big++;
          for (j = 0; j < nobj; j++)
@@ -3054,8 +3145,8 @@ ira_build (bool loops_p)
            }
        }
       fprintf (ira_dump_file, "  regions=%d, blocks=%d, points=%d\n",
-              VEC_length (loop_p, ira_loops.larray), n_basic_blocks,
-              ira_max_point);
+              current_loops == NULL ? 1 : VEC_length (loop_p, ira_loops.larray),
+              n_basic_blocks, ira_max_point);
       fprintf (ira_dump_file,
               "    allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\n",
               ira_allocnos_num, nr_big, ira_copies_num, n, nr);