From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 3DAAC3858C54 for ; Mon, 15 Jan 2024 12:59:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DAAC3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3DAAC3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705323589; cv=none; b=Aycw+lebLtRrou+b3JYOzmtB1tI/L6iaMY2zS5Sqrg9w/yF8VagGwvpQG7aWzLLbeCVLJTt5ln/43uuUBqIa0+Vg777kP2SlHBHZq04Cvj8P+prO7nKYz9uROAB/1Za3FGQK5yMnQiSbt3IV7tLHBagIKKBz/Itqp23XZ7WJefI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705323589; c=relaxed/simple; bh=wqIDDssL6EV0+69x9O6RUFbpkMq+LjlGyHcmrcH0rhw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Ht1CXo6a3Bsz73nKTrIJ7e4zCJEAo5hndQq31hJsMQ6w4UqwZEmknkSzk2AHwdc0/2AI8YTvzsJGACv3n4OwFIHH0y/poJGVEkDkuJDTx9wIWES63QLtzhsS1MLFlv1P9F1LHb8oMDlkyDrIF8CoyZ5kecGAWTjyfnhmGi/70zc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28e5b5eafb1so113668a91.1 for ; Mon, 15 Jan 2024 04:59:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705323575; x=1705928375; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LKa8FRAP3+AIPMLQmojAQ4qGqmTCrSZpPkcmebR1uUQ=; b=oaV/dMLl+yADO9nhgb9HTJF965EBHUZWABqaf4uisG5kXdjCNkJ31F+b3TmeOgZiQj jmPhOgnoMKAwkKr41/x5DJcPjf8BC+T3wkFsB8X0DPMdCjEKIPP7Sn4L2NX1DFsD/D+P c+fShw0VB8ZsdjKOvvml9aXT+EnHZW61p3NroXMu3s5kg/bHRV407OO7ubc0/6owGrY5 8TjP87Eb2TPRULrmIPzjXeHPVpDF003Guh6sWpxCszw1xTpkLCAMXeOoDbSusHgw8atD ngX2Gs/fnyul3yA1cGVTjgFEAp4neGHj1daKJMKnE4isJGM+NiWver9cqcRfIXzpE5/e 7eAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705323575; x=1705928375; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LKa8FRAP3+AIPMLQmojAQ4qGqmTCrSZpPkcmebR1uUQ=; b=TOdlWdURyXnuuZU8/IQDUTnX7pQ2AXZ1zEy4t1P4hh9w13OR9ddvM+2iYijKmEhKAU h1A0BxDaQ04fdFPF55RhMlhy1BMexDQZHjApX4+f4/Sz7vPlvNTvHGPihtHpvcBpFFow ENXKFpVjoeEM4l5VbmXx25RknMU9coJLum9W8LL6WBzh+dkWYgCgsmWCOlwRFLf6OMK+ 7EdxaTXCFcl3sUGB23TxW+Mgrv7jiacjy9QOjIHNOt757wGIeemhyBt2l8DDH6DU0+oQ e2Bq/+h9G4N1FVB1sPrXSoPMYjgpug7m3rJXTp9a54PD/7drnveydhcVGS+Fv7CSDLxQ Nspw== X-Gm-Message-State: AOJu0Yzpe1DlLNvsYTt0v+gXwq0DObA5YEo8VAnJ4+RZHgcKhKwgw+5R H4W0hDaRlAxKwcngdqPNtenuns+K5ovrwvwzAtMKlV0FfhF3ao/KENyLOAKGZw== X-Google-Smtp-Source: AGHT+IHuxdvzWuSOZ6Ywzu7QA74Ji5kz6t8ICsswnoohThv8lDYwkmXohFI5P++PG8Z+u09KuSECT+k0q0NWvxPKypA= X-Received: by 2002:a17:90b:1b0b:b0:28d:2e64:88ae with SMTP id nu11-20020a17090b1b0b00b0028d2e6488aemr9149572pjb.2.1705323575175; Mon, 15 Jan 2024 04:59:35 -0800 (PST) MIME-Version: 1.0 References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> <20231122111415.815147-4-maxim.kuvyrkov@linaro.org> In-Reply-To: <20231122111415.815147-4-maxim.kuvyrkov@linaro.org> From: Maxim Kuvyrkov Date: Mon, 15 Jan 2024 16:59:23 +0400 Message-ID: Subject: Re: [PATCH v3 3/8] Simplify handling of INSN_ and EXPR_LISTs in sched-rgn.cc To: gcc-patches@gcc.gnu.org Cc: Bernd Schmidt , Vladimir Makarov , Jeff Law , Alexander Monakov , Richard Guenther Content-Type: multipart/alternative; boundary="000000000000ecff95060efb952f" X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000ecff95060efb952f Content-Type: text/plain; charset="UTF-8" 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 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 --000000000000ecff95060efb952f--