This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IRA improvements 4/4


On 07/07/10 07:31, Vladimir Makarov wrote:
  This is the last patch to speed up IRA.  The big part of the patch
decreases allocno structure footprint (more than 2 times) improving
data locality.  The patch also contains manual optimizations of some
critical loops.

Is the patch ok to commit the patch to the trunk?

2010-07-07 Vladimir Makarov <vmakarov@redhat.com>

   * ira-build.c: (ira_create_allocno): Remove initialization of
   ALLOCNO_MEM_OPTIMIZED_DEST, ALLOCNO_MEM_OPTIMIZED_DEST_P,
   ALLOCNO_SOMEWHERE_RENAMED_P, ALLOCNO_CHILD_RENAMED_P,
   ALLOCNO_IN_GRAPH_P, ALLOCNO_MAY_BE_SPILLED_P, ALLOCNO_COLORABLE_P,
   ALLOCNO_NEXT_BUCKET_ALLOCNO, ALLOCNO_PREV_BUCKET_ALLOCNO,
   ALLOCNO_FIRST_COALESCED_ALLOCNO, ALLOCNO_NEXT_COALESCED_ALLOCNO,
   ALLOCNO_PROFITABLE_HARD_REGS, ALLOCNO_HARD_REGS_NODE,
   ALLOCNO_HARD_REGS_SUBNODES_START, ALLOCNO_HARD_REGS_SUBNODES_NUM.
   Initialize ALLOCNO_ADD_DATA.
   (copy_info_to_removed_store_destinations): Use ALLOCNO_EMIT_DATA
   instead of ALLOCNO_MEM_OPTIMIZED_DEST_P and ALLOCNO_REG.
   (ira_flattening): Ditto.  Use ALLOCNO_EMIT_DATA instead of
   ALLOCNO_MEM_OPTIMIZED_DEST and ALLOCNO_SOMEWHERE_RENAMED_P.
     * ira.c (ira_reallocate): Remove.
   (setup_pressure_classes): Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.
   (setup_allocno_assignment_flags): Use ALLOCNO_EMIT_DATA.
   (ira): Call ira_initiate_emit_data and ira_finish_emit_data.
     * ira-color.c: Use ALLOCNO_COLOR_DATA instead of
   ALLOCNO_IN_GRAPH_P, ALLOCNO_MAY_BE_SPILLED_P, ALLOCNO_COLORABLE_P,
   ALLOCNO_AVAILABLE_REGS_NUM, ALLOCNO_NEXT_BUCKET_ALLOCNO,
   ALLOCNO_PREV_BUCKET_ALLOCNO. ALLOCNO_TEMP,
   ALLOCNO_PROFITABLE_HARD_REGS, ALLOCNO_HARD_REGS_NODE,
   ALLOCNO_HARD_REGS_SUBNODES_START, ALLOCNO_HARD_REGS_SUBNODES_NUM.
   (allocno_hard_regs_t, allocno_hard_regs_node_t): Move from
   ira-int.h.
   (struct allocno_hard_regs, struct allocno_hard_regs_node): Ditto.
   (struct color_data): New.
   (color_data_t): New typedef.
   (allocno_color_data): New definition.
   (ALLOCNO_COLOR_DATA): New macro.
       (update_copy_costs, calculate_allocno_spill_cost,
   move_spill_restore, update_curr_costs): Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.
   (allocno_spill_priority): Make it inline.
   (color_pass): Allocate and free allocno_color_data.
   (struct coalesce_data): New.
   (allocno_coalesce_data): New definition.
   (ALLOCNO_COALESCE_DATA): New macro.
   (merge_allocnos, coalesced_allocno_conflict_p, coalesce_allocnos,
   setup_coalesced_allocno_costs_and_nums,
   collect_spilled_coalesced_allocnos,
   slot_coalesced_allocno_live_ranges_intersect_p,
   setup_slot_coalesced_allocno_live_ranges, coalesce_spill_slots):
   Use ALLOCNO_COALESCED_DATA instead of
   ALLOCNO_FIRST_COALESCED_ALLOCNO, ALLOCNO_NEXT_COALESCED_ALLOCNO,
   ALLOCNO_TEMP.
   (ira_sort_regnos_for_alter_reg): Ditto.  Allocate and free
   allocno_coalesce_data.

   * ira-conflicts.c (build_conflict_bit_table): Optimize.
   (process_regs_for_copy): Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.
   (build_allocno_conflicts): Optimize.

   * ira-costs.c (struct cost_classes): New member hard_regno_index.
   (setup_cost_classes): New.
   (setup_regno_cost_classes_by_aclass): Call setup_cost_classes.
   (setup_regno_cost_classes_by_mode): Ditto.
   (record_address_regs): Fix overflow code.
   (scan_one_insn): Ditto.
   (find_costs_and_classes): Ditto.  Move setting cost classes to the
   loop start.
   (setup_allocno_class_and_costs): Use member hard_regno_index.
   (ira_tune_allocno_costs): Fix overflow code.
     * ira-costs.c (cost_classes, cost_classes_num): Remove.
   (struct cost_classes, cost_classes_t, const_cost_classes_t,
   regno_cost_classes, cost_classes_hash, cost_classes_eq,
   cost_classes_del, cost_classes_htab, cost_classes_mode_cache,
   initiate_regno_cost_classes, setup_regno_cost_classes_by_aclass,
   setup_regno_cost_classes_by_mode, finish_regno_cost_classes): New.
   (record_reg_classes): Optimize.  Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost, ira_may_move_in_cost, and
   ira_may_move_out_cost instead of ira_get_register_move_cost and
   ira_get_may_move_cost.
   (record_address_regs): Ditto.
   (scan_one_insn): Optimize.
   (find_costs_and_classes): Optimize.  Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.
   (process_bb_node_for_hard_reg_moves): Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.

   * ira-emit.c: Use ALLOCNO_EMIT_DATA instead of ALLOCNO_REG,
   ALLOCNO_CHILD_RENAMED_P, ALLOCNO_MEM_OPTIMIZED_DEST,
   ALLOCNO_MEM_OPTIMIZED_DEST_P, and ALLOCNO_SOMEWHERE_RENAMED_P.
   (ira_allocno_emit_data, void_p, new_allocno_emit_data_vec): New
   definitions.
   (ira_initiate_emit_data, ira_finish_emit_data,
   create_new_allocno): New functions.
   (modify_move_list): Call create_new_alloc instead of
   ira_create_allocno.  Call ira_set_allocno_class instead of
   ira_set_allocno_cover_class.
   (emit_move_list): Call ira_init_register_move_cost_if_necessary.
   Use ira_register_move_cost instead of ira_get_register_move_cost.

   * ira-int.h (allocno_hard_regs_t, allocno_hard_regs_node_t): Move
   to ira-color.c.
   (struct allocno_hard_regs, struct allocno_hard_regs_node): Ditto.
   (struct ira_allocno): Make mode and aclass a bitfield.  Move other
   bitfield after mode.  Make hard_regno a short int.  Remove reg.
   Remove first_coalesced_allocno and next_coalesced_allocno.  Move
   mem_optimized_dest_p, somewhere_renamed_p, child_renamed_p, reg,
   and mem_optimized_dest into struct ira_emit_data.  Remove
   in_graph_p, may_be_spilled_p, splay_removed_p,
   left_conflicts_size, available_regs_num, next_bucket_allocno,
   prev_bucket_allocno, temp, colorable_p, profitable_hard_regs,
   hard_regs_node, hard_regs_subnodes_start, hard_regs_subnodes_num.
   Add new member add_data.
   (ALLOCNO_IN_GRAPH_P, ALLOCNO_MAY_BE_SPILLED_P,
   ALLOCNO_COLORABLE_P, ALLOCNO_AVAILABLE_REGS_NUM,
   ALLOCNO_NEXT_BUCKET_ALLOCNO, ALLOCNO_PREV_BUCKET_ALLOCNO,
   ALLOCNO_TEMP, ALLOCNO_FIRST_COALESCED_ALLOCNO,
   ALLOCNO_NEXT_COALESCED_ALLOCNO, ALLOCNO_PROFITABLE_HARD_REGS,
   ALLOCNO_HARD_REGS_SUBNODES_START, ALLOCNO_HARD_REGS_SUBNODES_NUM):
   Remove.
   (ALLOCNO_ADD_DATA): New macro.
   (ira_emit_data_t): New typedef.
   (struct ira_emit_data): New.  Move mem_optimized_dest_p,
   somewhere_renamed_p, child_renamed_p, reg, mem_optimized_dest from
   struct ira_allocno.
   (ALLOCNO_EMIT_DATA): New macro.
   (ira_allocno_emit_data): New.
   (ira_remove_allocno_copy_from_list, ira_reallocate): Remove.
   (ira_initiate_emit_data, ira_finish_emit_data): New.
   (ira_get_register_move_cost, ira_get_may_move_cost): Remove.
   (ira_init_register_move_cost_if_necessary): New.
   (ira_allocno_conflict_iter_next): Merge into
   ira_allocno_conflict_iter_cond.
   (FOR_EACH_ALLOCNO_CONFLICT): Don't use
   ira_allocno_conflict_iter_next.

   * ira-live.c: (process_single_reg_class_operands): Call
   ira_init_register_move_cost_if_necessary.  Use
   ira_register_move_cost instead of ira_get_register_move_cost.
This is almost exclusively a mechanical patch with a few other things thrown in which are difficult to find due to the large mechanical changes. In the future, it would probably help to separate primarily mechanical changes from micro-optimization of loops and other unrelated stuff.

Someone (I forget who) suggested accessor functions/macros which I think is a fine idea and was going to suggest it myself when I first started looking at the patch.

@ -1331,13 +1440,14 @@ assign_hard_reg (ira_allocno_t a, bool r
       }
       }
   if (! retry_p)
+    /* Take into account preferences of allocnos connected by copies to
+       the conflict allocnos.  */
+    update_conflict_hard_regno_costs (full_costs, aclass, true);
+
+  /* Take preferences of allocnos connected by copies into
+     account.  */
+  if (! retry_p)
     {
-      /* Take into account preferences of allocnos connected by copies
-     to the conflict allocnos.  */
-      update_conflict_hard_regno_costs (full_costs, aclass, true);
-
-      /* Take preferences of allocnos connected by copies into
-     account.  */
       start_update_cost ();
       queue_update_cost (a, COST_HOP_DIVISOR);
       update_conflict_hard_regno_costs (full_costs, aclass, false);
I don't see the point of this hunk and there aren't any changes to assign_hard_reg mentioned in the ChangeLog.


I'd generally be OK with this patch going into the mainline, though integration probably needs to be coordinated with Bernd's work and it'd need an independent bootstrap/test cycle since I suspect it wasn't tested independent of the removal of cover classes work (which I still haven't looked at in any detail).



Jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]