From patchwork Sun Sep 5 16:11:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1524781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=fsJClFvg; dkim-atps=neutral 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=) Received: from sourceware.org (server2.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 4H2c5B2wCjz9sPf for ; Mon, 6 Sep 2021 02:13:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAE923877438 for ; Sun, 5 Sep 2021 16:12:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAE923877438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630858374; bh=ceSL292pTMjkFJ9aZcuDm+N/UyG4rfg5tu/R6F44XZ4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fsJClFvg3IYFlP9TpHRPdElwd3FG0pzIFnKOuOCZKpeu8KzidfAo5ha8+aaegM9YY jsZcFts+UGHKCFS084C49mQl5rBFsn4CHM0d03BPL61R/5C8P6mxHAJIFQIoqeMVu+ bc/8NSjanEog2zBVFVU8OsbRyjvBTdqo7iZzJW5I= 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 ESMTP id AB2FF3858401 for ; Sun, 5 Sep 2021 16:12:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB2FF3858401 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-33-Hw7A3wQSOaCRghGDjypB2Q-1; Sun, 05 Sep 2021 12:12:09 -0400 X-MC-Unique: Hw7A3wQSOaCRghGDjypB2Q-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 863C0835DE1; Sun, 5 Sep 2021 16:12:08 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 185CE60BF1; Sun, 5 Sep 2021 16:12:07 +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 185GC5Mo848868 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 5 Sep 2021 18:12:05 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 185GC45b848867; Sun, 5 Sep 2021 18:12:04 +0200 To: GCC patches Subject: [COMMITTED] Make the path solver's range_of_stmt() handle all statements. Date: Sun, 5 Sep 2021 18:11:54 +0200 Message-Id: <20210905161154.848779-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, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The path solver's range_of_stmt() was handcuffed to only fold GIMPLE_COND statements, since those were the only statements the backward threader needed to resolve. However, there is no need for this restriction, as the folding code is perfectly capable of folding any statement. This can be the case when trying to fold other statements in the final block of a path (for instance, in the forward threader as it tries to fold candidate statements along a path). Tested on x86-64 Linux. gcc/ChangeLog: * gimple-range-path.cc (path_range_query::range_of_stmt): Remove GIMPLE_COND special casing. (path_range_query::range_defined_in_block): Use range_of_stmt instead of calling fold_range directly. --- gcc/gimple-range-path.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index f4509b5a726..a4fa3b296ff 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -155,7 +155,6 @@ path_range_query::unreachable_path_p () } // Return the range of STMT at the end of the path being analyzed. -// Anything but the final conditional in a BB will return VARYING. bool path_range_query::range_of_stmt (irange &r, gimple *stmt, tree) @@ -165,10 +164,9 @@ path_range_query::range_of_stmt (irange &r, gimple *stmt, tree) if (!irange::supports_type_p (type)) return false; - if (gimple_code (stmt) == GIMPLE_COND && fold_range (r, stmt, this)) - return true; + if (!fold_range (r, stmt, this)) + r.set_varying (type); - r.set_varying (type); return true; } @@ -237,7 +235,7 @@ path_range_query::range_defined_in_block (irange &r, tree name, basic_block bb) if (gimple_code (def_stmt) == GIMPLE_PHI) ssa_range_in_phi (r, as_a (def_stmt)); - else if (!fold_range (r, def_stmt, this)) + else if (!range_of_stmt (r, def_stmt, name)) r.set_varying (TREE_TYPE (name)); if (bb)