Message ID | 44815a60-2cd4-9408-64a9-d718163bca71@ventanamicro.com |
---|---|
State | Committed |
Commit | 89b5a316cffa4a9fa2504e776a4cdc2ef492f00b |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 62826385482D for <patchwork@sourceware.org>; Fri, 30 Sep 2022 23:06:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 118ED3858C55 for <gcc-patches@gcc.gnu.org>; Fri, 30 Sep 2022 23:05:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 118ED3858C55 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pg1-x532.google.com with SMTP id r62so5297498pgr.12 for <gcc-patches@gcc.gnu.org>; Fri, 30 Sep 2022 16:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date; bh=wFTGlnvoVgoLAqY4ZL1AU78hUPgh7uuYoy03AwtDfqg=; b=EMPsVfQcfS8N2PH9ppekbGxZ2BXaEXVvx6b8UqPm3LKfQzf53Ep6LOrXxYk0FNkBsE Bp07x2nb1kmnFRr9f22PoYARj6I7T5WGpJJIeGB5fhqhpkI1nFGQ4J6gHnETYltm9gyw 6AT8nkU/GApoJuIXk0sjWCgXEBi3vjG/1kDr4p0oqDJt0jn7nnle43ymlEda5QOARNAo TtRZyfT7n1HqrGGCg8HTrDANmk/lT6Y2b7Z9HjWMATZYYUsVbBMhXC49O+VnZrop4i/7 tgG+8Dqlx+c86kkh+/I9h4nsdtwuKijv8OXLY9DoWsGhicgpkpTPpgBfndQ/12r4Sk9J AW1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=wFTGlnvoVgoLAqY4ZL1AU78hUPgh7uuYoy03AwtDfqg=; b=wxMh900yRos9VukRbrxyKEMnGmA31NCpNqMQ0Tqi522hyAiT9QLl7ky0NLlryJloOA flyA+uDgw5780SzJ5v1FRl2FSfHUvFg8VZSjUYse02fVMHSxsOBui2nnHWRgKeHNEMaQ QZfjKl838ttfymbM2zbMBY59vFM7Ud0+WA/iANMy8nvLxmIxNzuDpIl2qwVMc5B9QqAI IRyqqd8sbXScH/LF1kQVtq0NKDS9X7k+LU9KypqoKtJd1VG2md12WS1bBE+ya6YOJgVk cmsQgCs/KDxe6h/uPuiY/mmhYuZY61m4RHBj+YIF5ftm1vFki0OJoI+RTyD2YGrDtvAX lgIg== X-Gm-Message-State: ACrzQf1ArD/3W/C//MW+EB5mRfVvCp2gbjZlOq+3fdawRRLAoNTckWzn YIjsjeU4bkJvN/xOuiHwJAIsHDhud7MXAeCT X-Google-Smtp-Source: AMsMyM4is1hAgZuKuOyia2bNeFSQMOtFbhA3+c3xZ7Sbqbo3LRMRvGE16Q9hEItg7eItri5I4c0OCQ== X-Received: by 2002:a63:ff22:0:b0:43c:7840:bea3 with SMTP id k34-20020a63ff22000000b0043c7840bea3mr9414736pgi.362.1664579148795; Fri, 30 Sep 2022 16:05:48 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id e64-20020a17090a6fc600b002004760a66csm2204714pjk.13.2022.09.30.16.05.47 for <gcc-patches@gcc.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Sep 2022 16:05:48 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------Bt0DvJ0uIuZd6QBsHb25tZx3" Message-ID: <44815a60-2cd4-9408-64a9-d718163bca71@ventanamicro.com> Date: Fri, 30 Sep 2022 17:05:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Content-Language: en-US To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org> From: Jeff Law <jlaw@ventanamicro.com> Subject: [committed] Minor cleanup/prep in DOM X-Spam-Status: No, score=-13.0 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 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.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[committed] Minor cleanup/prep in DOM
|
|
Commit Message
Jeff Law
Sept. 30, 2022, 11:05 p.m. UTC
It's a bit weird that free_dom_edge_info leaves a dangling pointer in e->aux. Not sure what I was thinking. There's two callers. One wipes e->aux immediately after the call, the other attaches a newly created object immediately after the call. So we can wipe e->aux within the call and simplify one of the two call sites. This is preparatory work for a minor optimization where we want to detect another class of edge equivalences in DOM (until something better is available) and either attach them an existing edge_info structure or create a new one if one doesn't currently exist for a given edge. Bootstrapped and regression tested on x86_64. Installing on the trunk. Jeff commit fbd95c027edcc169cc3b40806375fbabc08500e0 Author: Jeff Law <jeffreyalaw@gmail.com> Date: Fri Sep 30 18:59:24 2022 -0400 Minor cleanup/prep in DOM It's a bit weird that free_dom_edge_info leaves a dangling pointer in e->aux. Not sure what I was thinking. There's two callers. One wipes e->aux immediately after the call, the other attaches a newly created object immediately after the call. So we can wipe e->aux within the call and simplify one of the two call sites. This is preparatory work for a minor optimization where we want to detect another class of edge equivalences in DOM (until something better is available) and either attach them an existing edge_info structure or create a new one if one doesn't currently exist for a given edge. gcc/ * tree-ssa-dom.cc (free_dom_edge_info): Clear e->aux too. (free_all_edge_infos): Do not clear e->aux here.
Comments
On Fri, Sep 30, 2022 at 4:06 PM Jeff Law <jlaw@ventanamicro.com> wrote: > > > It's a bit weird that free_dom_edge_info leaves a dangling pointer in > e->aux. Not sure what I was thinking. > > > There's two callers. One wipes e->aux immediately after the call, the > other attaches a newly created object immediately after the call. So we > can wipe e->aux within the call and simplify one of the two call sites. > > This is preparatory work for a minor optimization where we want to > detect another class of edge equivalences in DOM (until something better > is available) and either attach them an existing edge_info structure or > create a new one if one doesn't currently exist for a given edge. > > Bootstrapped and regression tested on x86_64. Installing on the trunk. > I got /export/gnu/import/git/sources/gcc/gcc/tree-ssa-dom.cc: In function ‘void record_edge_info(basic_block)’: /export/gnu/import/git/sources/gcc/gcc/tree-ssa-dom.cc:689:27: error: ‘dst’ was not declared in this scope; did you mean ‘dse’? 689 | if (dst == PHI_ARG_DEF (phi, !alternative)) | ^~~ | dse In file included from /export/gnu/import/git/sources/gcc/gcc/gimple-ssa.h:24, from /export/gnu/import/git/sources/gcc/gcc/ssa.h:27, from /export/gnu/import/git/sources/gcc/gcc/tree-ssa-dom.cc:28: /export/gnu/import/git/sources/gcc/gcc/tree-ssa-dom.cc:689:47: error: ‘phi’ was not declared in this scope; did you mean ‘gphi’? 689 | if (dst == PHI_ARG_DEF (phi, !alternative)) | ^~~ /export/gnu/import/git/sources/gcc/gcc/tree-ssa-operands.h:82:54: note: in definition of macro ‘PHI_ARG_DEF’ 82 | #define PHI_ARG_DEF(PHI, I) gimple_phi_arg_def ((PHI), (I)) | ^~~ make: *** [Makefile:1146: tree-ssa-dom.o] Error 1
On 9/30/22 18:07, H.J. Lu wrote: > On Fri, Sep 30, 2022 at 4:06 PM Jeff Law <jlaw@ventanamicro.com> wrote: >> >> It's a bit weird that free_dom_edge_info leaves a dangling pointer in >> e->aux. Not sure what I was thinking. >> >> >> There's two callers. One wipes e->aux immediately after the call, the >> other attaches a newly created object immediately after the call. So we >> can wipe e->aux within the call and simplify one of the two call sites. >> >> This is preparatory work for a minor optimization where we want to >> detect another class of edge equivalences in DOM (until something better >> is available) and either attach them an existing edge_info structure or >> create a new one if one doesn't currently exist for a given edge. >> >> Bootstrapped and regression tested on x86_64. Installing on the trunk. >> > I got [ ... ] Pushed wrong version. Sorry about that. Fixed by attached patch which just moves the test down to its proper position. Jeff commit aa360fbf68b11e54017e8fa5b1bdb87ce7c19188 Author: Jeff Law <jeffreyalaw@gmail.com> Date: Fri Sep 30 20:46:04 2022 -0400 Install correct patch version. gcc/ * tree-ssa-dom.cc (record_edge_info): Install correct version of patch. diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc index 8d8312ca350..e6b8dace5e9 100644 --- a/gcc/tree-ssa-dom.cc +++ b/gcc/tree-ssa-dom.cc @@ -684,11 +684,6 @@ record_edge_info (basic_block bb) !gsi_end_p (gsi); gsi_next (&gsi)) { - /* If the other alternative is the same as the result, - then this is a degenerate and can be ignored. */ - if (dst == PHI_ARG_DEF (phi, !alternative)) - continue; - /* Now get the EDGE_INFO class so we can append it to our list. We want the successor edge where the destination is not the source of @@ -697,6 +692,11 @@ record_edge_info (basic_block bb) tree src = PHI_ARG_DEF (phi, alternative); tree dst = PHI_RESULT (phi); + /* If the other alternative is the same as the result, + then this is a degenerate and can be ignored. */ + if (dst == PHI_ARG_DEF (phi, !alternative)) + continue; + if (EDGE_SUCC (bb, 0)->dest != EDGE_PRED (bb, !alternative)->src) edge_info = (class edge_info *)EDGE_SUCC (bb, 0)->aux;
diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc index 84bef798f52..fa43dbe6c44 100644 --- a/gcc/tree-ssa-dom.cc +++ b/gcc/tree-ssa-dom.cc @@ -393,7 +393,8 @@ edge_info::record_simple_equiv (tree lhs, tree rhs) simple_equivalences.safe_push (equiv_pair (lhs, rhs)); } -/* Free the edge_info data attached to E, if it exists. */ +/* Free the edge_info data attached to E, if it exists and + clear e->aux. */ void free_dom_edge_info (edge e) @@ -402,6 +403,7 @@ free_dom_edge_info (edge e) if (edge_info) delete edge_info; + e->aux = NULL; } /* Free all EDGE_INFO structures associated with edges in the CFG. @@ -420,10 +422,7 @@ free_all_edge_infos (void) FOR_EACH_BB_FN (bb, cfun) { FOR_EACH_EDGE (e, ei, bb->preds) - { - free_dom_edge_info (e); - e->aux = NULL; - } + free_dom_edge_info (e); } }