From patchwork Mon Nov 29 16:21:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 48257 Return-Path: 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 C7F343857829 for ; Mon, 29 Nov 2021 16:22:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7F343857829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638202924; bh=f0ghqC3/A26F6mjkQCUu5U0sEk57w1QOpcATpUHmN3s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c3kss8RaaqnyhnOks5DxSTya7oHh5avWOb6Ge7JZ62H2H5+FyhaW/regSP8loniMh XHQ5mOLHfs7Pe5ZjFfF9vYGzBahJ12Wtbq7SxltSkef4IadST0XzgKLnB4RgWt2T9B ySQUE5RJ7+pXVN5jW1x9yg9kz08NTE/6XlMPOaHM= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 72A4C3858421 for ; Mon, 29 Nov 2021 16:21:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72A4C3858421 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251-FSkOcrXwOdqgbHk-BAiTAw-1; Mon, 29 Nov 2021 11:21:33 -0500 X-MC-Unique: FSkOcrXwOdqgbHk-BAiTAw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 336F736393 for ; Mon, 29 Nov 2021 16:21:32 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.111]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8707100EBAD; Mon, 29 Nov 2021 16:21:31 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 1ATGLSgO122600 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 17:21:29 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1ATGLSqX122599; Mon, 29 Nov 2021 17:21:28 +0100 To: GCC patches Subject: [PATCH] path solver: Use only one ssa_global_cache. Date: Mon, 29 Nov 2021 17:21:25 +0100 Message-Id: <20211129162125.122494-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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_H3, 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-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" We're using a temporary range cache while computing ranges for PHIs to make sure the real cache doesn't get set until all PHIs are computed. With the ltrans beast in LTO mode this causes undue overhead. Since we already have a bitmap to indicate whether there's a cache entry, we can avoid the extra cache object by clearing it while PHIs are being calculated. Tested on x86-64 Linux. OK for trunk? gcc/ChangeLog: PR tree-optimization/103409 * gimple-range-path.cc (path_range_query::compute_ranges_in_phis): Do all the work with just one ssa_global_cache. * gimple-range-path.h: Remove m_tmp_phi_cache. --- gcc/gimple-range-path.cc | 23 +++++++++++------------ gcc/gimple-range-path.h | 2 -- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index b9c71226c1c..15ef72fd492 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -375,30 +375,29 @@ void path_range_query::compute_ranges_in_phis (basic_block bb) { int_range_max r; - gphi_iterator iter; + auto_bitmap phi_set; // PHIs must be resolved simultaneously on entry to the block // because any dependencies must be satistifed with values on entry. // Thus, we calculate all PHIs first, and then update the cache at // the end. - m_tmp_phi_cache.clear (); - for (iter = gsi_start_phis (bb); !gsi_end_p (iter); gsi_next (&iter)) + for (auto iter = gsi_start_phis (bb); !gsi_end_p (iter); gsi_next (&iter)) { gphi *phi = iter.phi (); tree name = gimple_phi_result (phi); if (import_p (name) && range_defined_in_block (r, name, bb)) - m_tmp_phi_cache.set_global_range (name, r); - } - for (iter = gsi_start_phis (bb); !gsi_end_p (iter); gsi_next (&iter)) - { - gphi *phi = iter.phi (); - tree name = gimple_phi_result (phi); - - if (m_tmp_phi_cache.get_global_range (r, name)) - set_cache (r, name); + { + unsigned v = SSA_NAME_VERSION (name); + set_cache (r, name); + bitmap_set_bit (phi_set, v); + // Pretend we don't have a cache entry for this name until + // we're done with all PHIs. + bitmap_clear_bit (m_has_cache_entry, v); + } } + bitmap_ior_into (m_has_cache_entry, phi_set); } // Compute ranges defined in the current block, or exported to the diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index 57a9ae9bdcd..77c92c07bc1 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -82,8 +82,6 @@ private: // Range cache for SSA names. ssa_global_cache *m_cache; - ssa_global_cache m_tmp_phi_cache; - // Set for each SSA that has an active entry in the cache. bitmap m_has_cache_entry;