Hello,

This fixes the long-standing enhancement request to use DF_LIVE in
IRA. To quote the first comment in the PR:

IRA should be using the DF-LIVE sets, which are smaller than the DF-LR
sets when they are available (typically at O2 and above). The proper
sets can be conveniently accessed using the df_get_live_[in,out]
functions which use DF-LIVE if it is available and fall back to DF-LR
if it is not.

I thought that DF_LIVE wasn't available at -O1 in IRA, but
interestingly ira.c:ira() adds it to the DF-problems list in that case
already:

$ grep -C3 -n df_live_add ira.c
4160-
4161-  if (optimize == 1)
4162-    {
4163:      df_live_add_problem ();
4164-      df_live_set_all_dirty ();
4165-    }
4166-#ifdef ENABLE_CHECKING

So DF_LIVE is already being computed for IRA. It's just not being used
because the DF_LR_{IN,OUT} macros are used instead of the
df_get_live_{in,out} functions. With my patch, the DF_LIVE sets are
used, which results in marginally faster compile times for my set of
cc1-i files on power64 and on x86_64, as well as smaller code. There's
also a good speedup for the PR54146 test case.

Only reload.c still uses the DF_LR_OUT. The comment in
find_dummy_reload() suggests this is intentional.

I also fond a bug in IRA:

4392-     touch the artificial uses and defs.  */
4393-  df_finish_pass (true);
4394-  if (optimize > 1)
4395:    df_live_add_problem ();
4396-  df_scan_alloc (NULL);
4397-  df_scan_blocks ();
4398-

At optimize>1 the DF_LIVE problem is already always computed. I think
the idea here was to *remove* the DF_LIVE problem at -O1, which is
also part of the attached patch.
(Perhaps we should even simply not add the DF_LIVE problem at -O1, but
that can be done in a follow-up patch if necessary.)

Bootstrapped and tested (with default checking and with release
checking) on powerpc64-unknown-linux-gnu and x86_64-unknown-linux-gnu.
OK for trunk?

Ciao!
Steven

        PR rtl-optimization/38711
        * df.h (df_get_live_out, df_get_live_in): Make static inline functions.
        * df-problems.c (df_get_live_out, df_get_live_in): Moved to df.h.
        * ira-lives.c (process_bb_node_lives): Use df_get_live_out instead of
        DF_LR_OUT.
        * ira-build.c (create_bb_allocnos): Likewise.
        (create_loop_allocnos): Likewise, and use df_get_live_in instead of
        DF_LR_IN.
        * ira-emit.c (generate_edge_moves): Likewise.
        (add_ranges_and_copies): Likewise.
        * ira.c (mark_elimination): Update DF_LR and DF_LIVE.
        (build_insn_chain): Use df_get_live_out instead of DF_LR_OUT.
        (do_reload): Remove the DF_LIVE problem for -O1.
        * ira-color.c (ira_loop_edge_freq): Use df_get_live_out instead of
        DF_LR_OUT, and df_get_live_in instead of DF_LR_IN.

Attachment: ira-speedup-3.diff
Description: Binary data

Reply via email to