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 929D5384A00F for ; Fri, 3 Sep 2021 13:30:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 929D5384A00F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-74-Gy4n9RCuOlqs-Z_pmOUfGg-1; Fri, 03 Sep 2021 09:29:57 -0400 X-MC-Unique: Gy4n9RCuOlqs-Z_pmOUfGg-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 4EA5A824FA6; Fri, 3 Sep 2021 13:29:55 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C662B104B53A; Fri, 3 Sep 2021 13:29:54 +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 183DTpnN729615 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 3 Sep 2021 15:29:52 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 183DTpCR729614; Fri, 3 Sep 2021 15:29:51 +0200 From: Aldy Hernandez To: GCC patches Subject: [COMMITTED] Use non-null knowledge in path_range_query. Date: Fri, 3 Sep 2021 15:29:49 +0200 Message-Id: <20210903132949.729488-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.2 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_H2, 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: Fri, 03 Sep 2021 13:30:01 -0000 [Jeff, I'm CCing you to keep you in the loop on changes that will impact jump threading. Since we're using one engine, any changes to the either ranger or the path solver, is likely to improve jump threading.] This patch improves ranges for pointers we are interested in a path, by using the non-null class from the ranger. This allows us to thread more paths with minimal effort. Tested on x86-64 Linux. gcc/ChangeLog: * gimple-range-path.cc (path_range_query::range_defined_in_block): Adjust for non-null. (path_range_query::adjust_for_non_null_uses): New. (path_range_query::precompute_ranges): Call adjust_for_non_null_uses. * gimple-range-path.h: Add m_non_null and adjust_for_non_null_uses. --- gcc/gimple-range-path.cc | 33 +++++++++++++++++++++++++++++++++ gcc/gimple-range-path.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 6d6e5eb6635..db15eb3ff22 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -221,6 +221,9 @@ path_range_query::range_defined_in_block (irange &r, tree name, basic_block bb) else if (!fold_range (r, def_stmt, this)) r.set_varying (TREE_TYPE (name)); + if (bb) + m_non_null.adjust_range (r, name, bb); + if (DEBUG_SOLVER && (bb || !r.varying_p ())) { fprintf (dump_file, "range_defined_in_block (BB%d) for ", bb ? bb->index : -1); @@ -302,6 +305,35 @@ path_range_query::precompute_ranges_in_block (basic_block bb) } } +// Adjust all pointer imports in BB with non-null information. + +void +path_range_query::adjust_for_non_null_uses (basic_block bb) +{ + int_range_max r; + bitmap_iterator bi; + unsigned i; + + EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) + { + tree name = ssa_name (i); + + if (!POINTER_TYPE_P (TREE_TYPE (name))) + continue; + + if (get_cache (r, name)) + { + if (r.nonzero_p ()) + continue; + } + else + r.set_varying (TREE_TYPE (name)); + + if (m_non_null.adjust_range (r, name, bb)) + set_cache (r, name); + } +} + // Precompute the ranges for IMPORTS along PATH. // // IMPORTS are the set of SSA names, any of which could potentially @@ -332,6 +364,7 @@ path_range_query::precompute_ranges (const vec &path, basic_block bb = curr_bb (); precompute_ranges_in_block (bb); + adjust_for_non_null_uses (bb); if (at_exit ()) break; diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index 0d2d2e7f75d..51773131040 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -53,6 +53,7 @@ private: // Methods to precompute ranges for the given path. bool range_defined_in_block (irange &, tree name, basic_block bb); void precompute_ranges_in_block (basic_block bb); + void adjust_for_non_null_uses (basic_block bb); void ssa_range_in_phi (irange &r, gphi *phi); // Path navigation. @@ -80,6 +81,7 @@ private: const bitmap_head *m_imports; gimple_ranger &m_ranger; + non_null_ref m_non_null; }; #endif // GCC_TREE_SSA_THREADSOLVER_H -- 2.31.1