From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 63137385AC2D for ; Wed, 14 Jul 2021 22:14:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 63137385AC2D Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-pHR-dvH3NuGNXrbB0SzLdw-1; Wed, 14 Jul 2021 18:14:24 -0400 X-MC-Unique: pHR-dvH3NuGNXrbB0SzLdw-1 Received: by mail-qk1-f199.google.com with SMTP id x2-20020ae9e6420000b02903b8853778c2so2267206qkl.18 for ; Wed, 14 Jul 2021 15:14:24 -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:from:subject:message-id:date:user-agent :mime-version:content-language; bh=e3F4mKVBOaOD02injdmlS6iyXeF3CVXE24FvlMYh2p0=; b=W8WrpLj9EjtqBl+D/EeCXiQHpr3NpZnK7f6Z8TtiTftXSpIxodbUK9029vQvpKCeG7 vRLqyB3Yp/MXsy1GocF3FGwKDm1AmkGVcB+KDQNNcoj8OKZ+684Z6lFw1c2iqaRPftOq OiTjyGHZtz97gpq4AUsw96GuKQf2TMEHLo7s9rQwoZ0Ykoh/LxFmzrr9g/f+fYzL3wj7 AdGiEq8zs4JQEx62oDQQVZdyNs197dApwqOk5L3ziO2zUHORgJdyfGe0K0WlSMOk8ZZV m8+8nhkP0Y6DQjsI2vMCjX46h1YKjahB3r8SJWSSflKPlPyd5hOP5Lrn23+HTBTgCARN QSmQ== X-Gm-Message-State: AOAM5319y18g7t+9yosP2rmofjL/4J9bPScaHsu/3mm13kNLUXVt9ELb ewLT3QpGsT1RWLDjLmUadp7CWnVr8gZsn93K4NwJsQTTN/1EN68egcGuvJNgJO1EXAH15VIHsJh m/NzoEgoUTm0WR1Oz2WQ1fIWtL+YRlzUjmLYsPWYf2G7B6dSsG9N5tbbu4btT+x5wC5xb2g== X-Received: by 2002:a05:620a:9c5:: with SMTP id y5mr167247qky.339.1626300863999; Wed, 14 Jul 2021 15:14:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVPfJMtPs3EpKWsc6jkWuYgED2ebqbHP9jDvKxQ3aZuh0m9wVDiYjjXNTAnkINGdoZNxJcjw== X-Received: by 2002:a05:620a:9c5:: with SMTP id y5mr167227qky.339.1626300863776; Wed, 14 Jul 2021 15:14:23 -0700 (PDT) Received: from [192.168.0.102] ([104.219.122.163]) by smtp.gmail.com with ESMTPSA id 7sm1290058qtx.33.2021.07.14.15.14.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 15:14:23 -0700 (PDT) To: gcc-patches From: Andrew MacLeod Subject: [GCC 11] [COMMITTED] Do not continue propagating values which cannot be set, properly. Message-ID: Date: Wed, 14 Jul 2021 18:14:21 -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-Type: multipart/mixed; boundary="------------E5183249BDE11160306D417D" Content-Language: en-CA X-Spam-Status: No, score=-12.3 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_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 14 Jul 2021 22:14:27 -0000 This is a multi-part message in MIME format. --------------E5183249BDE11160306D417D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit If the on-entry cache cannot properly represent a range, do not continue trying to propagate it.  Adapted version of a GCC 12 patch which works in conjuction with the sparse on entry cache update. Bootstrapped on x86_64-pc-linux-gnu with no regressions. pushed. Andrew --------------E5183249BDE11160306D417D Content-Type: text/x-patch; charset=UTF-8; name="0007-Do-not-continue-propagating-values-which-cannot-be-s.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0007-Do-not-continue-propagating-values-which-cannot-be-s.pa"; filename*1="tch" >From 85c22c517e9571d1f0f487fd708fbb01f36f172a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 22 Jun 2021 17:46:05 -0400 Subject: [PATCH 7/8] Do not continue propagating values which cannot be set properly. If the on-entry cache cannot properly represent a range, do not continue trying to propagate it. PR tree-optimization/101148 PR tree-optimization/101014 * gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust. (ranger_cache::~ranger_cache): Adjust. (ranger_cache::block_range): Check if propagation disallowed. (ranger_cache::propagate_cache): Disallow propagation if new value can't be stored properly. * gimple-range-cache.h (ranger_cache::m_propfail): New member. --- gcc/gimple-range-cache.cc | 11 ++++++++++- gcc/gimple-range-cache.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 610d4c50531..ff0084545ab 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -742,10 +742,12 @@ ranger_cache::ranger_cache (gimple_ranger &q) : query (q) m_poor_value_list.safe_grow_cleared (20); m_poor_value_list.truncate (0); m_temporal = new temporal_cache; + m_propfail = BITMAP_ALLOC (NULL); } ranger_cache::~ranger_cache () { + BITMAP_FREE (m_propfail); delete m_temporal; m_poor_value_list.release (); m_workback.release (); @@ -958,7 +960,9 @@ ranger_cache::block_range (irange &r, basic_block bb, tree name, bool calc) void ranger_cache::add_to_update (basic_block bb) { - if (!m_update_list.contains (bb)) + // If propagation has failed for BB, or its already in the list, don't + // add it again. + if (!bitmap_bit_p (m_propfail, bb->index) && !m_update_list.contains (bb)) m_update_list.quick_push (bb); } @@ -975,6 +979,7 @@ ranger_cache::propagate_cache (tree name) int_range_max current_range; int_range_max e_range; + gcc_checking_assert (bitmap_empty_p (m_propfail)); // Process each block by seeing if its calculated range on entry is // the same as its cached value. If there is a difference, update // the cache to reflect the new value, and check to see if any @@ -1031,6 +1036,9 @@ ranger_cache::propagate_cache (tree name) if (new_range != current_range) { bool ok_p = m_on_entry.set_bb_range (name, bb, new_range); + // If the cache couldn't set the value, mark it as failed. + if (!ok_p) + bitmap_set_bit (m_propfail, bb->index); if (DEBUG_RANGE_CACHE) { if (!ok_p) @@ -1060,6 +1068,7 @@ ranger_cache::propagate_cache (tree name) print_generic_expr (dump_file, name, TDF_SLIM); fprintf (dump_file, "\n"); } + bitmap_clear (m_propfail); } // 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 f82816f10c1..d536f09940f 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -115,6 +115,7 @@ private: void propagate_updated_value (tree name, basic_block bb); + bitmap m_propfail; vec m_workback; vec m_update_list; -- 2.17.2 --------------E5183249BDE11160306D417D--