From patchwork Wed Jun 23 14:27:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1496163 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@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=I3WL2BDP; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4G95Hk2vKPz9sWc for ; Thu, 24 Jun 2021 00:29:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA4A139874C0 for ; Wed, 23 Jun 2021 14:29:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA4A139874C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1624458560; bh=r8L8JSPNB9+NGFZpnOKXZm6UbqcZJcpPKCKP7/NzdwQ=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=I3WL2BDPfiwXQL/wnAEgCDq+YSTDN2taZEbVrItSLacRJ2q4FvYjXkvqqmKuIdYRh OKlyaRcoNkyRMbfOw1x8XpRKExTP5xyUoZOD0kTZX0EJXEdubrns1OClOPqK48UceF m+JFBjo2px2UYIi0qJNaV2xv38yLTYxVXXqLF6Jg= 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 DADB8383F423 for ; Wed, 23 Jun 2021 14:27:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DADB8383F423 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-MGJPdFLJMxi7cmOVZw4oSg-1; Wed, 23 Jun 2021 10:27:21 -0400 X-MC-Unique: MGJPdFLJMxi7cmOVZw4oSg-1 Received: by mail-qk1-f198.google.com with SMTP id 14-20020a37060e0000b02903aad32851d2so2726736qkg.1 for ; Wed, 23 Jun 2021 07:27:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language; bh=r8L8JSPNB9+NGFZpnOKXZm6UbqcZJcpPKCKP7/NzdwQ=; b=nsF8prJtDYlfsZh3Cg0SFUgW2NyuFjMgtHmnjaSM8mmWPyRvRf2Ueg3Ws5iPvGW7UM 1lFjJQX3PAQLBNimPD8X0Wtqx6UYzD+/n5KmhiGFeANMG3INjL62QeGAm4PTy57SWaSL bq/acgeqQx6uT55fwUe5MbbsTYUKgNIo5VsXysHhWZMkKKGXzfqJ6qHUQQtapw+D0+yq jsi5rjlhyyBlOuy5Y6N+gBhfQGa37VjLOHnpknZSIvHcDoYgA96q7JxCjhbpOsSxb7bZ r+O8IkR/gWwt3WgUm2GOZSIDUN1d6k22BUPfXlfSYJ/ggCKqJuqwgu6lAz+Fk23bAJ/6 y6BA== X-Gm-Message-State: AOAM530Zvnf8aYdxXkW1UGBEMIixGZCDucRUrM9TJE/w9LDMtjy3dqS1 r/kjrlyQlGjRvkbrvztIGxVee3DitEorrUMlgsZLl6xtSctBSxYy+WBfAQJ+OhaiGq1Vzo+vs/g iBknQL06fVSW5QZT3pw== X-Received: by 2002:a05:622a:1a83:: with SMTP id s3mr145012qtc.347.1624458440796; Wed, 23 Jun 2021 07:27:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhnNclI/ax/qIgzj/JVODnmv7GhZM9xDdzSuBFAQCD2uTdHnyKJx9FaRpQsl9F3cl8wAaH/A== X-Received: by 2002:a05:622a:1a83:: with SMTP id s3mr145002qtc.347.1624458440662; Wed, 23 Jun 2021 07:27:20 -0700 (PDT) Received: from ?IPv6:2607:fea8:a241:4600::58f9? ([2607:fea8:a241:4600::58f9]) by smtp.gmail.com with ESMTPSA id z12sm67247qtq.25.2021.06.23.07.27.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 07:27:20 -0700 (PDT) Subject: [COMMITTED 1/2] Adjust on_entry cache to indicate if the value was set properly. To: gcc-patches Message-ID: Date: Wed, 23 Jun 2021 10:27:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The introduction of the sparse bitmap on-entry cache for large BB functions also introduced the concept that the value we ask to be written to the cache may not be properly represented.  It is limited to 15 unique ranges for any given ssa-name, then  it reverts to varying for any additional values to be safe. This patch adds a boolean return value to the cache set routines, allowing us to check if the value was properly written. Other than that, no functional change. Bootstrap on x86_64-pc-linux-gnu with no regressions.  pushed. Andrew From ca4d381662c37733b2a1d49d6c8f5fcfc1348f3d Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 22 Jun 2021 17:21:32 -0400 Subject: [PATCH 2/4] Adjust on_entry cache to indicate if the value was set properly. * gimple-range-cache.cc (class ssa_block_ranges): Adjust prototype. (sbr_vector::set_bb_range): Return true. (class sbr_sparse_bitmap): Adjust. (sbr_sparse_bitmap::set_bb_range): Return value. (block_range_cache::set_bb_range): Return value. (ranger_cache::propagate_cache): Use return value to print msg. * gimple-range-cache.h (class block_range_cache): Adjust. --- gcc/gimple-range-cache.cc | 44 ++++++++++++++++++++++----------------- gcc/gimple-range-cache.h | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 4347485cf98..bdecd212691 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -132,7 +132,7 @@ non_null_ref::process_name (tree name) class ssa_block_ranges { public: - virtual void set_bb_range (const basic_block bb, const irange &r) = 0; + virtual bool set_bb_range (const basic_block bb, const irange &r) = 0; virtual bool get_bb_range (irange &r, const basic_block bb) = 0; virtual bool bb_range_p (const basic_block bb) = 0; @@ -165,7 +165,7 @@ class sbr_vector : public ssa_block_ranges public: sbr_vector (tree t, irange_allocator *allocator); - virtual void set_bb_range (const basic_block bb, const irange &r) OVERRIDE; + virtual bool set_bb_range (const basic_block bb, const irange &r) OVERRIDE; virtual bool get_bb_range (irange &r, const basic_block bb) OVERRIDE; virtual bool bb_range_p (const basic_block bb) OVERRIDE; protected: @@ -196,7 +196,7 @@ sbr_vector::sbr_vector (tree t, irange_allocator *allocator) // Set the range for block BB to be R. -void +bool sbr_vector::set_bb_range (const basic_block bb, const irange &r) { irange *m; @@ -208,6 +208,7 @@ sbr_vector::set_bb_range (const basic_block bb, const irange &r) else m = m_irange_allocator->allocate (r); m_tab[bb->index] = m; + return true; } // Return the range associated with block BB in R. Return false if @@ -252,7 +253,7 @@ class sbr_sparse_bitmap : public ssa_block_ranges { public: sbr_sparse_bitmap (tree t, irange_allocator *allocator, bitmap_obstack *bm); - virtual void set_bb_range (const basic_block bb, const irange &r) OVERRIDE; + virtual bool set_bb_range (const basic_block bb, const irange &r) OVERRIDE; virtual bool get_bb_range (irange &r, const basic_block bb) OVERRIDE; virtual bool bb_range_p (const basic_block bb) OVERRIDE; private: @@ -312,13 +313,13 @@ sbr_sparse_bitmap::bitmap_get_quad (const_bitmap head, int quad) // Set the range on entry to basic block BB to R. -void +bool sbr_sparse_bitmap::set_bb_range (const basic_block bb, const irange &r) { if (r.undefined_p ()) { bitmap_set_quad (bitvec, bb->index, SBR_UNDEF); - return; + return true; } // Loop thru the values to see if R is already present. @@ -328,11 +329,11 @@ sbr_sparse_bitmap::set_bb_range (const basic_block bb, const irange &r) if (!m_range[x]) m_range[x] = m_irange_allocator->allocate (r); bitmap_set_quad (bitvec, bb->index, x + 1); - return; + return true; } // All values are taken, default to VARYING. bitmap_set_quad (bitvec, bb->index, SBR_VARYING); - return; + return false; } // Return the range associated with block BB in R. Return false if @@ -387,7 +388,7 @@ block_range_cache::~block_range_cache () // Set the range for NAME on entry to block BB to R. // If it has not been accessed yet, allocate it first. -void +bool block_range_cache::set_bb_range (tree name, const basic_block bb, const irange &r) { @@ -413,7 +414,7 @@ block_range_cache::set_bb_range (tree name, const basic_block bb, m_irange_allocator); } } - m_ssa_ranges[v]->set_bb_range (bb, r); + return m_ssa_ranges[v]->set_bb_range (bb, r); } @@ -1061,13 +1062,18 @@ ranger_cache::propagate_cache (tree name) // If the range on entry has changed, update it. if (new_range != current_range) { + bool ok_p = m_on_entry.set_bb_range (name, bb, new_range); if (DEBUG_RANGE_CACHE) { - fprintf (dump_file, " Updating range to "); - new_range.dump (dump_file); + if (!ok_p) + fprintf (dump_file, " Cache failure to store value."); + else + { + fprintf (dump_file, " Updating range to "); + new_range.dump (dump_file); + } fprintf (dump_file, "\n Updating blocks :"); } - m_on_entry.set_bb_range (name, bb, new_range); // Mark each successor that has a range to re-check its range FOR_EACH_EDGE (e, ei, bb->succs) if (m_on_entry.bb_range_p (name, e->dest)) @@ -1080,12 +1086,12 @@ ranger_cache::propagate_cache (tree name) fprintf (dump_file, "\n"); } } - if (DEBUG_RANGE_CACHE) - { - fprintf (dump_file, "DONE visiting blocks for "); - print_generic_expr (dump_file, name, TDF_SLIM); - fprintf (dump_file, "\n"); - } + if (DEBUG_RANGE_CACHE) + { + fprintf (dump_file, "DONE visiting blocks for "); + print_generic_expr (dump_file, name, TDF_SLIM); + fprintf (dump_file, "\n"); + } } // Check to see if an update to the value for NAME in BB has any effect diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 04150ea54a8..1d2e1b99200 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -50,7 +50,7 @@ public: block_range_cache (); ~block_range_cache (); - void set_bb_range (tree name, const basic_block bb, const irange &r); + bool set_bb_range (tree name, const basic_block bb, const irange &r); bool get_bb_range (irange &r, tree name, const basic_block bb); bool bb_range_p (tree name, const basic_block bb); -- 2.17.2