From patchwork Thu Nov 4 14:39:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 47057 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 8114D3858D35 for ; Thu, 4 Nov 2021 14:42:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8114D3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636036944; bh=JtI8Dae9Wu2fRBmTOweDrcSgDo1SseSQXnWrpAqmTYA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=fiHP9BJUPxwAMgQ1gw+pZ8I1krIYvvT2OpYXACg81J/6QAfg3+SXC9/4sBV3ptqSE v2sFnmR83EM0y6RHtbRxLh7xTMCuBLMQ4Z0/r03laG9zGkQeAqcCWyCjhRNPd+lZWH SHAg/xuT92skhq+tY7IFvGIwkPAavWXpWxN37wsQ= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id AF31B3858D35 for ; Thu, 4 Nov 2021 14:40:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF31B3858D35 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-431-ZSsDgKznNwejg7zM-J6nZg-1; Thu, 04 Nov 2021 10:40:00 -0400 X-MC-Unique: ZSsDgKznNwejg7zM-J6nZg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB63987D54C for ; Thu, 4 Nov 2021 14:39:59 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 718FC60BF1; Thu, 4 Nov 2021 14:39:59 +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 1A4Edvvf1102490 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 4 Nov 2021 15:39:57 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1A4Edv1J1102489; Thu, 4 Nov 2021 15:39:57 +0100 To: GCC patches Subject: [COMMITTED] path solver: Prefer range_of_expr instead of range_on_edge. Date: Thu, 4 Nov 2021 15:39:48 +0100 Message-Id: <20211104143948.1102399-3-aldyh@redhat.com> In-Reply-To: <20211104143948.1102399-1-aldyh@redhat.com> References: <20211104143948.1102399-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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_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-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" The range_of_expr method provides better caching than range_on_edge. If we have a statement, we can just it and avoid the range_on_edge dance. Plus we can use all the range_of_expr fanciness. Tested on x86-64 and ppc64le Linux with the usual regstrap. I also verified that the before and after number of threads was the same or greater in a suite of .ii files from a bootstrap. gcc/ChangeLog: PR tree-optimization/102943 * gimple-range-path.cc (path_range_query::range_on_path_entry): Prefer range_of_expr unless there are no statements in the BB. --- gcc/gimple-range-path.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 42309886c94..9175651e896 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -135,10 +135,24 @@ void path_range_query::range_on_path_entry (irange &r, tree name) { gcc_checking_assert (defined_outside_path (name)); - int_range_max tmp; basic_block entry = entry_bb (); - bool changed = false; + // Prefer to use range_of_expr if we have a statement to look at, + // since it has better caching than range_on_edge. + gimple *last = last_stmt (entry); + if (last) + { + if (m_ranger.range_of_expr (r, name, last)) + return; + gcc_unreachable (); + } + + // If we have no statement, look at all the incoming ranges to the + // block. This can happen when we're querying a block with only an + // outgoing edge (no statement but the fall through edge), but for + // which we can determine a range on entry to the block. + int_range_max tmp; + bool changed = false; r.set_undefined (); for (unsigned i = 0; i < EDGE_COUNT (entry->preds); ++i) {