From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
To: gcc-patches@gcc.gnu.org
Cc: Bernd Schmidt <bernds_cb1@t-online.de>,
Vladimir Makarov <vmakarov@redhat.com>,
Jeff Law <jeffreyalaw@gmail.com>,
Alexander Monakov <amonakov@ispras.ru>,
Richard Guenther <richard.guenther@gmail.com>
Subject: Re: [PATCH v3 3/8] Simplify handling of INSN_ and EXPR_LISTs in sched-rgn.cc
Date: Mon, 15 Jan 2024 16:59:23 +0400 [thread overview]
Message-ID: <CAD0Vn-CNG+hvhqCwpYwTrTe=JfRnyJiK9sPwuK6LxqLUQhcZog@mail.gmail.com> (raw)
In-Reply-To: <20231122111415.815147-4-maxim.kuvyrkov@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 8379 bytes --]
Dear RTL maintainers,
Gently ping. This patch adds a couple of new functions to lists.cc, which
then are used to simplify logic in the scheduler. OK to merge?
On Wed, 22 Nov 2023 at 15:14, Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
wrote:
> This patch simplifies logic behind deps_join(), which will be
> important for the upcoming improvements of sched-deps.cc logging.
>
> The only functional change is that when deps_join() is called with
> empty state for the 2nd argument, it will not reverse INSN_ and
> EXPR_LISTs in the 1st argument. Before this patch the lists were
> reversed due to use of concat_*_LIST(). Now, with copy_*_LIST()
> used for this case, the lists will remain in the original order.
>
> gcc/ChangeLog:
>
> * lists.cc (copy_EXPR_LIST, concat_EXPR_LIST): New functions.
> * rtl.h (copy_EXPR_LIST, concat_EXPR_LIST): Declare.
> * sched-rgn.cc (concat_insn_list, concat_expr_list): New helpers.
> (concat_insn_mem_list): Simplify.
> (deps_join): Update
> ---
> gcc/lists.cc | 30 +++++++++++++++++++++++++++-
> gcc/rtl.h | 4 +++-
> gcc/sched-rgn.cc | 51 +++++++++++++++++++++++++++---------------------
> 3 files changed, 61 insertions(+), 24 deletions(-)
>
> diff --git a/gcc/lists.cc b/gcc/lists.cc
> index 2cdf37ad533..83e7bf32176 100644
> --- a/gcc/lists.cc
> +++ b/gcc/lists.cc
> @@ -160,6 +160,24 @@ free_INSN_LIST_list (rtx_insn_list **listp)
> free_list ((rtx *)listp, &unused_insn_list);
> }
>
> +/* Make a copy of the EXPR_LIST list LINK and return it. */
> +rtx_expr_list *
> +copy_EXPR_LIST (rtx_expr_list *link)
> +{
> + rtx_expr_list *new_queue;
> + rtx_expr_list **pqueue = &new_queue;
> +
> + for (; link; link = link->next ())
> + {
> + rtx x = link->element ();
> + rtx_expr_list *newlink = alloc_EXPR_LIST (REG_NOTE_KIND (link), x,
> NULL);
> + *pqueue = newlink;
> + pqueue = (rtx_expr_list **)&XEXP (newlink, 1);
> + }
> + *pqueue = NULL;
> + return new_queue;
> +}
> +
> /* Make a copy of the INSN_LIST list LINK and return it. */
> rtx_insn_list *
> copy_INSN_LIST (rtx_insn_list *link)
> @@ -178,12 +196,22 @@ copy_INSN_LIST (rtx_insn_list *link)
> return new_queue;
> }
>
> +/* Duplicate the EXPR_LIST elements of COPY and prepend them to OLD. */
> +rtx_expr_list *
> +concat_EXPR_LIST (rtx_expr_list *copy, rtx_expr_list *old)
> +{
> + rtx_expr_list *new_rtx = old;
> + for (; copy; copy = copy->next ())
> + new_rtx = alloc_EXPR_LIST (REG_NOTE_KIND (copy), copy->element (),
> new_rtx);
> + return new_rtx;
> +}
> +
> /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD. */
> rtx_insn_list *
> concat_INSN_LIST (rtx_insn_list *copy, rtx_insn_list *old)
> {
> rtx_insn_list *new_rtx = old;
> - for (; copy ; copy = copy->next ())
> + for (; copy; copy = copy->next ())
> {
> new_rtx = alloc_INSN_LIST (copy->insn (), new_rtx);
> PUT_REG_NOTE_KIND (new_rtx, REG_NOTE_KIND (copy));
> diff --git a/gcc/rtl.h b/gcc/rtl.h
> index e4b6cc0dbb5..7e952d7cbeb 100644
> --- a/gcc/rtl.h
> +++ b/gcc/rtl.h
> @@ -3764,10 +3764,12 @@ extern void free_EXPR_LIST_list (rtx_expr_list **);
> extern void free_INSN_LIST_list (rtx_insn_list **);
> extern void free_EXPR_LIST_node (rtx);
> extern void free_INSN_LIST_node (rtx);
> +extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx);
> extern rtx_insn_list *alloc_INSN_LIST (rtx, rtx);
> +extern rtx_expr_list *copy_EXPR_LIST (rtx_expr_list *);
> extern rtx_insn_list *copy_INSN_LIST (rtx_insn_list *);
> +extern rtx_expr_list *concat_EXPR_LIST (rtx_expr_list *, rtx_expr_list *);
> extern rtx_insn_list *concat_INSN_LIST (rtx_insn_list *, rtx_insn_list *);
> -extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx);
> extern void remove_free_INSN_LIST_elem (rtx_insn *, rtx_insn_list **);
> extern rtx remove_list_elem (rtx, rtx *);
> extern rtx_insn *remove_free_INSN_LIST_node (rtx_insn_list **);
> diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc
> index e5964f54ead..da3ec0458ff 100644
> --- a/gcc/sched-rgn.cc
> +++ b/gcc/sched-rgn.cc
> @@ -2585,25 +2585,32 @@ add_branch_dependences (rtx_insn *head, rtx_insn
> *tail)
>
> static class deps_desc *bb_deps;
>
> +/* Return a new insn_list with all the elements from the two input
> lists. */
> +static rtx_insn_list *
> +concat_insn_list (rtx_insn_list *copy, rtx_insn_list *old)
> +{
> + if (!old)
> + return copy_INSN_LIST (copy);
> + return concat_INSN_LIST (copy, old);
> +}
> +
> +/* Return a new expr_list with all the elements from the two input
> lists. */
> +static rtx_expr_list *
> +concat_expr_list (rtx_expr_list *copy, rtx_expr_list *old)
> +{
> + if (!old)
> + return copy_EXPR_LIST (copy);
> + return concat_EXPR_LIST (copy, old);
> +}
> +
> static void
> concat_insn_mem_list (rtx_insn_list *copy_insns,
> rtx_expr_list *copy_mems,
> rtx_insn_list **old_insns_p,
> rtx_expr_list **old_mems_p)
> {
> - rtx_insn_list *new_insns = *old_insns_p;
> - rtx_expr_list *new_mems = *old_mems_p;
> -
> - while (copy_insns)
> - {
> - new_insns = alloc_INSN_LIST (copy_insns->insn (), new_insns);
> - new_mems = alloc_EXPR_LIST (VOIDmode, copy_mems->element (),
> new_mems);
> - copy_insns = copy_insns->next ();
> - copy_mems = copy_mems->next ();
> - }
> -
> - *old_insns_p = new_insns;
> - *old_mems_p = new_mems;
> + *old_insns_p = concat_insn_list (copy_insns, *old_insns_p);
> + *old_mems_p = concat_expr_list (copy_mems, *old_mems_p);
> }
>
> /* Join PRED_DEPS to the SUCC_DEPS. */
> @@ -2619,11 +2626,11 @@ deps_join (class deps_desc *succ_deps, class
> deps_desc *pred_deps)
> struct deps_reg *pred_rl = &pred_deps->reg_last[reg];
> struct deps_reg *succ_rl = &succ_deps->reg_last[reg];
>
> - succ_rl->uses = concat_INSN_LIST (pred_rl->uses, succ_rl->uses);
> - succ_rl->sets = concat_INSN_LIST (pred_rl->sets, succ_rl->sets);
> + succ_rl->uses = concat_insn_list (pred_rl->uses, succ_rl->uses);
> + succ_rl->sets = concat_insn_list (pred_rl->sets, succ_rl->sets);
> succ_rl->implicit_sets
> - = concat_INSN_LIST (pred_rl->implicit_sets,
> succ_rl->implicit_sets);
> - succ_rl->clobbers = concat_INSN_LIST (pred_rl->clobbers,
> + = concat_insn_list (pred_rl->implicit_sets,
> succ_rl->implicit_sets);
> + succ_rl->clobbers = concat_insn_list (pred_rl->clobbers,
> succ_rl->clobbers);
> succ_rl->uses_length += pred_rl->uses_length;
> succ_rl->clobbers_length += pred_rl->clobbers_length;
> @@ -2641,10 +2648,10 @@ deps_join (class deps_desc *succ_deps, class
> deps_desc *pred_deps)
> &succ_deps->pending_write_mems);
>
> succ_deps->pending_jump_insns
> - = concat_INSN_LIST (pred_deps->pending_jump_insns,
> + = concat_insn_list (pred_deps->pending_jump_insns,
> succ_deps->pending_jump_insns);
> succ_deps->last_pending_memory_flush
> - = concat_INSN_LIST (pred_deps->last_pending_memory_flush,
> + = concat_insn_list (pred_deps->last_pending_memory_flush,
> succ_deps->last_pending_memory_flush);
>
> succ_deps->pending_read_list_length +=
> pred_deps->pending_read_list_length;
> @@ -2653,17 +2660,17 @@ deps_join (class deps_desc *succ_deps, class
> deps_desc *pred_deps)
>
> /* last_function_call is inherited by successor. */
> succ_deps->last_function_call
> - = concat_INSN_LIST (pred_deps->last_function_call,
> + = concat_insn_list (pred_deps->last_function_call,
> succ_deps->last_function_call);
>
> /* last_function_call_may_noreturn is inherited by successor. */
> succ_deps->last_function_call_may_noreturn
> - = concat_INSN_LIST (pred_deps->last_function_call_may_noreturn,
> + = concat_insn_list (pred_deps->last_function_call_may_noreturn,
> succ_deps->last_function_call_may_noreturn);
>
> /* sched_before_next_call is inherited by successor. */
> succ_deps->sched_before_next_call
> - = concat_INSN_LIST (pred_deps->sched_before_next_call,
> + = concat_insn_list (pred_deps->sched_before_next_call,
> succ_deps->sched_before_next_call);
> }
>
> --
> 2.34.1
>
>
--
Maxim Kuvyrkov
www.linaro.org
next prev parent reply other threads:[~2024-01-15 12:59 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 12:06 [PATCH 0/1] Avoid exponential behavior in scheduler and better logging Maxim Kuvyrkov
2023-11-20 12:06 ` [PATCH 1/1] sched-deps.cc (find_modifiable_mems): Avoid exponential behavior Maxim Kuvyrkov
2023-11-20 13:09 ` Richard Biener
2023-11-20 13:42 ` Maxim Kuvyrkov
2023-11-20 13:45 ` Richard Biener
2023-11-20 14:48 ` [PATCH v2] " Maxim Kuvyrkov
2023-11-20 18:59 ` [PATCH 1/1] " Maxim Kuvyrkov
2023-11-20 13:52 ` Alexander Monakov
2023-11-20 14:39 ` Maxim Kuvyrkov
2023-11-20 16:30 ` Alexander Monakov
2023-11-21 10:32 ` Maxim Kuvyrkov
2023-11-21 11:05 ` Alexander Monakov
2023-11-22 11:14 ` [PATCH v3 0/8] Avoid exponential behavior in scheduler and better logging Maxim Kuvyrkov
2023-11-22 11:14 ` [PATCH v3 1/8] sched-deps.cc (find_modifiable_mems): Avoid exponential behavior Maxim Kuvyrkov
2024-01-15 12:56 ` Maxim Kuvyrkov
2024-01-15 18:26 ` Vladimir Makarov
2024-01-16 14:52 ` Jeff Law
2024-01-17 6:51 ` Richard Biener
2024-01-17 7:39 ` Maxim Kuvyrkov
2024-01-17 15:02 ` Richard Biener
2024-01-17 15:05 ` Maxim Kuvyrkov
2024-01-17 15:44 ` Maxim Kuvyrkov
2024-01-17 18:54 ` H.J. Lu
2023-11-22 11:14 ` [PATCH v3 2/8] Unify implementations of print_hard_reg_set() Maxim Kuvyrkov
2023-11-22 15:04 ` Vladimir Makarov
2023-11-22 11:14 ` [PATCH v3 3/8] Simplify handling of INSN_ and EXPR_LISTs in sched-rgn.cc Maxim Kuvyrkov
2024-01-15 12:59 ` Maxim Kuvyrkov [this message]
2023-11-22 11:14 ` [PATCH v3 4/8] Improve and fix sched-deps.cc: dump_dep() and dump_lists() Maxim Kuvyrkov
2024-01-15 13:01 ` Maxim Kuvyrkov
2023-11-22 11:14 ` [PATCH v3 5/8] Add a bit more logging scheduler's dependency analysis Maxim Kuvyrkov
2024-01-15 13:04 ` Maxim Kuvyrkov
2023-11-22 11:14 ` [PATCH v3 6/8] sched_deps.cc: Simplify initialization of dependency contexts Maxim Kuvyrkov
2024-01-15 13:05 ` Maxim Kuvyrkov
2023-11-22 11:14 ` [PATCH v3 7/8] Improve logging of register data in scheduler dependency analysis Maxim Kuvyrkov
2024-01-15 13:06 ` Maxim Kuvyrkov
2023-11-22 11:14 ` [PATCH v3 8/8] Improve logging of scheduler dependency analysis context Maxim Kuvyrkov
2024-01-15 13:08 ` Maxim Kuvyrkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAD0Vn-CNG+hvhqCwpYwTrTe=JfRnyJiK9sPwuK6LxqLUQhcZog@mail.gmail.com' \
--to=maxim.kuvyrkov@linaro.org \
--cc=amonakov@ispras.ru \
--cc=bernds_cb1@t-online.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=richard.guenther@gmail.com \
--cc=vmakarov@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).