From patchwork Wed Nov 22 11:14:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746018 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239831wru; Wed, 22 Nov 2023 03:16:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVyQM5tUszt96jlKsHrmcFs1jHZwdLRTxyI4kYb6tMP3mpmeMKa7s4JIOqTVZIdNNDD1xP X-Received: by 2002:a05:620a:839a:b0:767:2076:5bee with SMTP id pb26-20020a05620a839a00b0076720765beemr2042053qkn.9.1700651766356; Wed, 22 Nov 2023 03:16:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651766; cv=pass; d=google.com; s=arc-20160816; b=qwp6zzc8VW/z3Q6wegCskV4Mkc3jIu63dcYCBwMTnwYlMrzWZSWrV0hAq+HodA9wrY 2WlyLwtBMFvhs5ny6hC+P1DMsbUtuu/N6QK7+TN+3b7W087k2sadtOm3uSCjmFmHf6K1 OX4xEXWV3wCjOCEx4vVqaRrTaQT25MTzJ2OrID5/62AF/eCg0CyFWTrjllxK0G2VSAGI LWPxQi+y4ZGQJhDHtH9zhbgRsYHaZW7OqTY45Q5f1wU1QTcy2JVFLXGvephgi9fItYMW bEULqlK5Z4MqYXRPYN3HDyIEsS1k1iHPASspbvLZEzbMOrSXtTYkDK8PbgexoI3Nq9hJ 9I+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=BvfCI4VJqG44br5dehknAPj4eJoBJiteLvh3KfojfYE6irIW7DLwWzizrlffsdP4gS OzorD+JenIqkV0ZT8hw/Z3O0loPHzzMqMXgbe1++MfkbaJjpafYfnBofmkrdEIShsXEl 83iHksgX9FJfwAoH8zVR6OCkxyuWbhX/h/jvuKA2I2lkdmeNh3hjAeUmYYGHROV8Mirc rkD9EwfEORc3vb6b3myi/a9QnrLgPAz5v3CS3fL27e4VkuiUDz7Sl5YNQ7uwKw2AI+5c mk+ZtMr/bLVWyz2Uheq5sLyEe+8LbIg5biNRa77mMpzY8KuaW0GaPxxWUGKpDFCznLiu /jIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BSVNWMfF; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s13-20020a05620a080d00b0077a4af92713si10968784qks.565.2023.11.22.03.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:16:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BSVNWMfF; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05767385B504 for ; Wed, 22 Nov 2023 11:16:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id B51603858C35 for ; Wed, 22 Nov 2023 11:14:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B51603858C35 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 B51603858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651698; cv=none; b=ATcTpneyZYzBVDCKdW2+QMN7eABulVNa6AWFv/Fc303U3nifppoOxuI6ccO6wggQajSKmn6byXl6O6lMTOkdmTMNGBpB7sgt2i83wIMFGLCvr+8HfjUcRVQ9fNfBw5smJvUkkEEoJ26sARVc/1xdgnZycRjqYBzK7QPZpvjQTNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651698; c=relaxed/simple; bh=oU2Cpqf5iJjKqz6POqe2yKnidKee4m8qgaP9zrdGbS0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=auXHAuPHHlQDlUCfoUG0WzhMcRAjbG7ZFgXTmK3kYROF13NfUT/KMGkPxqwEcjx4Qi4VLk2729LV+x4Zly8gkIMMhfLePhw311Uq/lWNtzvdrAqb1drhedNb2Yo5brJeemMp+RexJ/3KUTLvsLLbjJ8L2SCs1+UqWBpJJi2q/eE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637727e87.1 for ; Wed, 22 Nov 2023 03:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651694; x=1701256494; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; b=BSVNWMfFc6MFWQprQcRt4P/gLuiw4UuOYUm27w3YTlpp+r61Bz31NA9rHLJirauZYH jrr1UizFBLxZHY+LhM0nuyD38+xFXinSbZ68MuPbkK9s3SOlFh3JxpXDKASp+nhLosGI 9ykl5muttBMl6Cp1MFPuINejG5HKzFGhmu+2PqfwWmGJjkaWVx0lrAbux8jLtnQxumq+ SEOr3f8ZAiu9MtTEcwLVVaI+5imcLA5w1wK9lwU4Q3DlWkdBlAavPtayxpwmir2yHRLY 5COl8hpwgqe5bvRBv9zfwVcM9drC2yMCFpjxUilCmJazV5SPPieSqdPfClnfmjADdW7A 8mew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651694; x=1701256494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; b=QyfgmTVf05sWc8hEuQd8hkosLdOiNlMjuGX4OMlUlGEMN254OMseXxdMDWTgc4WQJQ EpjSl2vNtmKuQMwQ99m/RqUPQ47i9smqwukns5ooOAwc/11NI9DN4DBYW/FGLBAnUHIS 01ZqAacwjuakez3/FVm5u+Q7uBa3nvNhQCIk5lWQ+l7VtiwUjPmRWxM8N1IrP4LBzxTT +C0BlYWsWYHZpvBY7aiYRtjYEFuz2sn6gFeaANxb1bqHh4IxUIb4MTClMt3Jb3OuQfgy kb5iNy3vFshyFwcHKUVUyTEH+ZAFjqxycpgvDcgem9rOmHqYUswAZmzLe/BIqjCZ38TQ /BgA== X-Gm-Message-State: AOJu0YwggP/d4ZatM3DhsUMS0fGNc9cpYeI5V79PmozH3EAZl3ipEeTI tFq0GJaNpBj0CIe0DC6ZCOMCDRBL4a2akZcmGHjdwPs= X-Received: by 2002:a05:6512:2314:b0:507:9861:2be9 with SMTP id o20-20020a056512231400b0050798612be9mr1527173lfu.6.1700651694605; Wed, 22 Nov 2023 03:14:54 -0800 (PST) Received: from localhost.localdomain (static.225.72.216.95.clients.your-server.de. [95.216.72.225]) by smtp.gmail.com with ESMTPSA id t13-20020a195f0d000000b0050919538b00sm1848553lfb.79.2023.11.22.03.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:52 -0800 (PST) From: Maxim Kuvyrkov To: gcc-patches@gcc.gnu.org Cc: Maxim Kuvyrkov , Bernd Schmidt , Vladimir Makarov , Jeff Law , Alexander Monakov , Richard Guenther Subject: [PATCH v3 3/8] Simplify handling of INSN_ and EXPR_LISTs in sched-rgn.cc Date: Wed, 22 Nov 2023 11:14:10 +0000 Message-Id: <20231122111415.815147-4-maxim.kuvyrkov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patch=linaro.org@gcc.gnu.org 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); }