This is the mail archive of the 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]

[ira-improv] patch for new code dealing with hard reg preferences

  The following patch adds a new functionality to IRA to improve RA in
presence of hard registers in RTL.  IRA already had some mechanism
dealing with hard regs but it affected only pseudos in *the same insn*
containing hard register.  This technique was not good enough to
remove regmove pass code making transformations for matching
constraints (e.g. 2-op insn machine) although IRA can make better
decision for pseudos but still not enough good for hard registers.  So
just removing the code in regmove resulted in worse generated code

  On the other hand there are performance PRs which is a result of bad
decision in pre-mature optimization of regmove pass for matching

  We already have an IRA code propagating pseudo preferences to other
pseudos through net of copies.  We need the same code for better
dealing with hard register preferences.  The patch adds such code.  I
could modify structure ira_copy for this but decided to use new
separate structures as the copy structure is too big and we don't need
most of its fields for hard-register preferences.

  By the way, LRA has already code for dealing with hard register
preferences but in simplified way as we work on RTL mostly locally.

  This is not a final patch as the big part of regmove code and old
IRA code for hard register preferences are not removed.  This code is
just switched off by -fira-hard-reg-pref option.  I am going to play a
bit more with the new code and when I decide to submit it to trunk, I
remove the unnecessary code and the option.

  Right now, the results look pretty good for SPEC2000 on x86/x86-64.
The compiler is always faster (as a regmove RTL pass is switched
off), generates in average smaller code (the best is 0.05% decrease
for x86-64 SPECFP2000), and generates in average better code (0.6%
and 0.4% SPECFP2000 improvement on x86 and x86-64 correspondingly).
The results were gotten on Intel Core I7-2600 in -O3 optimization

  The patch was successfully bootstrapped on x86/x86-64 with the new
code switched on.

Committed as rev. 197525.

2013-04-05  Vladimir Makarov  <>

        * common.opt (fira-hard-reg-pref): New.
        * regmove.c (regmove_optimize): Don't call regmove_forward_pass
        for flag_ira_hard_reg_pref.
        * ira-int.h (ira_pref_t, allocno_prefs, ALLOCNO_PREFS): New.
        (struct ira_allocno_pref, ira_prefs, ira_prefs_num): New.
        (ira_debug_pref, ira_debug_prefs, ira_debug_allocno_prefs): New.
        (ira_create_pref, ira_create_copy): New.
        (ira_add_allocno_copy_to_list): Remove.
        (ira_swap_allocno_copy_ends_if_necessary): Ditto.
        (ira_pref_iterator, ira_pref_iter_init, ira_pref_iter_cond): New.
        (FOR_EACH_PREF): New.
        * ira-build.c (ira_prefs, ira_prefs_num): New.
        (ira_create_allocno): Reset preferences.
        (pref_pool, pref_vec, initiate_prefs, find_allocno_pref)
        (ira_create_pref, add_allocno_pref_to_list, ira_add_allocno_pref)
        (print_pref, ira_debug_pref, print_prefs, ira_debug_prefs)
        (print_allocno_prefs, ira_debug_allocno_prefs, finish_pref)
        (finish_prefs): New.
        (ira_add_allocno_copy_to_list): Rename to
        add_allocno_copy_to_list.  Make static.
        (ira_swap_allocno_copy_ends_if_necessary): Rename to
        swap_allocno_copy_ends_if_necessary.  Make static.
        (ira_build, ira_destroy): Initialize and finish the prefs.
        * ira-color.c (update_allocno_cost, update_costs_from_allocno):
        (update_copy_costs): Rename to update_costs_from_copies.  Use
        (update_costs_from_prefs, update_costs_from_copies): New.
        (assign_hard_reg): Call update_costs_from_prefs.
        (color_allocnos, color_pass): Ditto.
        * ira-costs.c (find_costs_and_classes): Improve code.  Add code for
        hard reg preferences.
        (process_bb_node_for_hard_reg_moves): Add code for hard reg

Attachment: pref.patch
Description: Text document

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