From patchwork Tue May 25 23:30:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1483796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=jwH1JKC0; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FqVh23xRJz9sCD for ; Wed, 26 May 2021 09:30:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B49F6385743D; Tue, 25 May 2021 23:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B49F6385743D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621985454; bh=YK4BLn3YwP0XMPYAchmdZ7ZCLHhTRFuuRTzif6jLAFg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jwH1JKC0wSsRgtLaXBYWmfT/to9Jkx6rrqaVaGZg8kVD4MGyUa0KpUOYlJrjPPwoj RF6vd9HE5j01RrXLMlErck02oMt6HaivXNxlakPzM3gBRHfVMMF5FHtgRefw7wOlqY ATzyaMAEaC4ANYZ2JDQdJ99X2yaXxGyMjhoYo3fk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 9E5333857419 for ; Tue, 25 May 2021 23:30:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9E5333857419 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-E4vCpn_SOOW1sTBVi5qU9w-1; Tue, 25 May 2021 19:30:47 -0400 X-MC-Unique: E4vCpn_SOOW1sTBVi5qU9w-1 Received: by mail-qv1-f71.google.com with SMTP id i14-20020a0cf10e0000b02901eeced6480dso30486205qvl.4 for ; Tue, 25 May 2021 16:30:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=YK4BLn3YwP0XMPYAchmdZ7ZCLHhTRFuuRTzif6jLAFg=; b=Qk0YRFsSUW/QjnZ51JqoLhgkmGgcJxBoO1lrTR0KXTe1lgkjXFGmuPR4zjWFrX5Qzt 9hpFNsAfDEToiJsjVkXXfwl2Hc2IWBbFXdslpbd65WQzYITwP4jfDt+8VmkHOSyTYmO4 94C06SRb5dyPYWK/POUtu9F4Sx/3IWrhVW/vWme76Ou574Ffa3MgOKfgyzvMHUDn37Bp Kjgbf7Q4Loqd49qJmY7SLOp39ldjVJ9P+lhGL5ftNxP3Xr9d85eRqKjN5DpYHAYaXOtW BsIFgKetMOcAc/iagfi2xnYEnmlfO3t2pDESHgzmXE3+UnLkDywZwRt34XINueU2ZGAo Wv9Q== X-Gm-Message-State: AOAM533/eIGdPN4piApTcSMhO7neZa4awT+TFjE6oXhHf4O5xw011tZO NudCS9jcfLUlHA5977hmGzk/4jVCEZB1LQpZBfusZk4sBHuBIFs4bB1o5vHY0t0oU7Vi3bhtoPx 5AYpRq7BOMjG2gw2FVQ== X-Received: by 2002:a05:6214:c2d:: with SMTP id a13mr40192493qvd.37.1621985446206; Tue, 25 May 2021 16:30:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyulcq/wxWqpSrTyHsBccM9mD6FzgjZizUyvt+meREL1XMnct+IfL4OfprmtQ3rpCuWaEVw6w== X-Received: by 2002:a05:6214:c2d:: with SMTP id a13mr40192484qvd.37.1621985446078; Tue, 25 May 2021 16:30:46 -0700 (PDT) Received: from ?IPv6:2607:fea8:a25d:e700::2b5? ([2607:fea8:a25d:e700::2b5]) by smtp.gmail.com with ESMTPSA id p17sm488369qkg.67.2021.05.25.16.30.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 May 2021 16:30:45 -0700 (PDT) To: gcc-patches Subject: [PATCH 4/8] Unify temporal cache with gori dependencies. Message-ID: Date: Tue, 25 May 2021 19:30:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The patch removes the custom temporal cache from GCC11 and replaces it with a simple timestamp vector and utilizes the direct dependants from gori_compute. This allows the registration of said dependencies to be handled generically by the simplified fold_stmt class thru the gori_compute class.  So All the dependency analysis is handled centrally in one place now. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 10b286ce335cca135a45a92581b28146f3e3209b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 25 May 2021 14:34:06 -0400 Subject: [PATCH 4/8] Unify temporal cache with gori dependencies. Move the temporal cache to strictly be a timestamp, and query GORI for the dependencies rather than trying to register and maintain them. * gimple-range-cache.cc (struct range_timestamp): Delete. (class temporal_cache): Adjust. (temporal_cache::get_timestamp): Delete. (temporal_cache::set_dependency): Delete. (temporal_cache::temporal_value): Adjust. (temporal_cache::current_p): Take dependencies as params. (temporal_cache::set_timestamp): Adjust. (temporal_cache::set_always_current): Adjust. (ranger_cache::get_non_stale_global_range): Adjust. (ranger_cache::register_dependency): Delete. * gimple-range-cache.h (class range_cache): Adjust. --- gcc/gimple-range-cache.cc | 116 +++++++++++--------------------------- gcc/gimple-range-cache.h | 1 - 2 files changed, 32 insertions(+), 85 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 8ad76048272..3969c4de220 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -474,43 +474,28 @@ ssa_global_cache::dump (FILE *f) // -------------------------------------------------------------------------- -// This struct provides a timestamp for a global range calculation. -// it contains the time counter, as well as a limited number of ssa-names -// that it is dependent upon. If the timestamp for any of the dependent names -// Are newer, then this range could need updating. - -struct range_timestamp -{ - unsigned time; - unsigned ssa1; - unsigned ssa2; -}; - // This class will manage the timestamps for each ssa_name. -// When a value is calcualted, its timestamp is set to the current time. -// The ssanames it is dependent on have already been calculated, so they will -// have older times. If one fo those values is ever calculated again, it -// will get a newer timestamp, and the "current_p" check will fail. +// When a value is calculated, the timestamp is set to the current time. +// Current time is then incremented. Any dependencies will already have +// been calculated, and will thus have older timestamps. +// If one of those values is ever calculated again, it will get a newer +// timestamp, and the "current_p" check will fail. class temporal_cache { public: temporal_cache (); ~temporal_cache (); - bool current_p (tree name) const; + bool current_p (tree name, tree dep1, tree dep2) const; void set_timestamp (tree name); - void set_dependency (tree name, tree dep); void set_always_current (tree name); private: unsigned temporal_value (unsigned ssa) const; - const range_timestamp *get_timestamp (unsigned ssa) const; - range_timestamp *get_timestamp (unsigned ssa); unsigned m_current_time; - vec m_timestamp; + vec m_timestamp; }; - inline temporal_cache::temporal_cache () { @@ -525,65 +510,35 @@ temporal_cache::~temporal_cache () m_timestamp.release (); } -// Return a pointer to the timetamp for ssa-name at index SSA, if there is -// one, otherwise return NULL. - -inline const range_timestamp * -temporal_cache::get_timestamp (unsigned ssa) const -{ - if (ssa >= m_timestamp.length ()) - return NULL; - return &(m_timestamp[ssa]); -} - -// Return a reference to the timetamp for ssa-name at index SSA. If the index -// is past the end of the vector, extend the vector. - -inline range_timestamp * -temporal_cache::get_timestamp (unsigned ssa) -{ - if (ssa >= m_timestamp.length ()) - m_timestamp.safe_grow_cleared (num_ssa_names + 20); - return &(m_timestamp[ssa]); -} - -// This routine will fill NAME's next operand slot with DEP if DEP is a valid -// SSA_NAME and there is a free slot. - -inline void -temporal_cache::set_dependency (tree name, tree dep) -{ - if (dep && TREE_CODE (dep) == SSA_NAME) - { - gcc_checking_assert (get_timestamp (SSA_NAME_VERSION (name))); - range_timestamp& ts = *(get_timestamp (SSA_NAME_VERSION (name))); - if (!ts.ssa1) - ts.ssa1 = SSA_NAME_VERSION (dep); - else if (!ts.ssa2 && ts.ssa1 != SSA_NAME_VERSION (name)) - ts.ssa2 = SSA_NAME_VERSION (dep); - } -} - // Return the timestamp value for SSA, or 0 if there isnt one. + inline unsigned temporal_cache::temporal_value (unsigned ssa) const { - const range_timestamp *ts = get_timestamp (ssa); - return ts ? ts->time : 0; + if (ssa >= m_timestamp.length ()) + return 0; + return m_timestamp[ssa]; } // Return TRUE if the timestampe for NAME is newer than any of its dependents. +// Up to 2 dependencies can be checked. bool -temporal_cache::current_p (tree name) const +temporal_cache::current_p (tree name, tree dep1, tree dep2) const { - const range_timestamp *ts = get_timestamp (SSA_NAME_VERSION (name)); - if (!ts || ts->time == 0) + unsigned ts = temporal_value (SSA_NAME_VERSION (name)); + if (ts == 0) return true; + // Any non-registered dependencies will have a value of 0 and thus be older. // Return true if time is newer than either dependent. - return ts->time > temporal_value (ts->ssa1) - && ts->time > temporal_value (ts->ssa2); + + if (dep1 && ts < temporal_value (SSA_NAME_VERSION (dep1))) + return false; + if (dep2 && ts < temporal_value (SSA_NAME_VERSION (dep2))) + return false; + + return true; } // This increments the global timer and sets the timestamp for NAME. @@ -591,8 +546,10 @@ temporal_cache::current_p (tree name) const inline void temporal_cache::set_timestamp (tree name) { - gcc_checking_assert (get_timestamp (SSA_NAME_VERSION (name))); - get_timestamp (SSA_NAME_VERSION (name))->time = ++m_current_time; + unsigned v = SSA_NAME_VERSION (name); + if (v >= m_timestamp.length ()) + m_timestamp.safe_grow_cleared (num_ssa_names + 20); + m_timestamp[v] = ++m_current_time; } // Set the timestamp to 0, marking it as "always up to date". @@ -600,11 +557,12 @@ temporal_cache::set_timestamp (tree name) inline void temporal_cache::set_always_current (tree name) { - gcc_checking_assert (get_timestamp (SSA_NAME_VERSION (name))); - get_timestamp (SSA_NAME_VERSION (name))->time = 0; + unsigned v = SSA_NAME_VERSION (name); + if (v >= m_timestamp.length ()) + m_timestamp.safe_grow_cleared (num_ssa_names + 20); + m_timestamp[v] = 0; } - // -------------------------------------------------------------------------- ranger_cache::ranger_cache (gimple_ranger &q) : query (q) @@ -682,7 +640,7 @@ ranger_cache::get_non_stale_global_range (irange &r, tree name) { if (m_globals.get_global_range (r, name)) { - if (m_temporal->current_p (name)) + if (m_temporal->current_p (name, depend1 (name), depend2 (name))) return true; } else @@ -728,16 +686,6 @@ ranger_cache::set_global_range (tree name, const irange &r) m_temporal->set_timestamp (name); } -// Register a dependency on DEP to name. If the timestamp for DEP is ever -// greateer than the timestamp for NAME, then it is newer and NAMEs value -// becomes stale. - -void -ranger_cache::register_dependency (tree name, tree dep) -{ - m_temporal->set_dependency (name, dep); -} - // Push a request for a new lookup in block BB of name. Return true if // the request is actually made (ie, isn't a duplicate). diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 15e6d0c61c4..fe781e0ad1b 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -98,7 +98,6 @@ public: bool get_global_range (irange &r, tree name) const; bool get_non_stale_global_range (irange &r, tree name); void set_global_range (tree name, const irange &r); - void register_dependency (tree name, tree dep); non_null_ref m_non_null; -- 2.17.2