From patchwork Tue Sep 21 16:53:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1530812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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=Rs7bLawm; 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 (ip-8-43-85-97.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 4HDSKG0rGBz9sRK for ; Wed, 22 Sep 2021 02:57:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5AB3385841A for ; Tue, 21 Sep 2021 16:57:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5AB3385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632243455; bh=3oTcb5l0QRns1ikVubp+1NdZ/4hQUXezmHVhEPFPCQk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Rs7bLawmSnRx2mgrz/XZEAROIKvV2ik4VJz1hJyTff9aTn+mAUTJED6/7ke3v/dO1 hcfBsfNLS2tjWAYooJeT/sZGIronP2sbixeiliTcrdL0FGxv07mWJrYp4z6t8xNiAQ Ek/bnhtDUMDuWHqDcGQqfBFgcd3C9j5VEoSRNYwE= 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 ESMTP id 84A48385843A for ; Tue, 21 Sep 2021 16:54:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 84A48385843A 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-417-AJPceUQsNliQq0zlVDK5Cg-1; Tue, 21 Sep 2021 12:54:09 -0400 X-MC-Unique: AJPceUQsNliQq0zlVDK5Cg-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 6796684A5E0; Tue, 21 Sep 2021 16:54:08 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.248]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F28851010424; Tue, 21 Sep 2021 16:54: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 18LGs5Kk414671 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 21 Sep 2021 18:54:05 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 18LGs5Pj414670; Tue, 21 Sep 2021 18:54:05 +0200 To: Andrew MacLeod Subject: [PATCH 3/7] Move postfold_gcond_edges into fur_source. Date: Tue, 21 Sep 2021 18:53:46 +0200 Message-Id: <20210921165350.414593-4-aldyh@redhat.com> In-Reply-To: <20210921165350.414593-1-aldyh@redhat.com> References: <20210921165350.414593-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.8 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 Cc: GCC patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The code registering outgoing edges from a cond is living in fold_using_range, which makes it difficult to be called from other places. Also, it refuses to register relations on the outgoing destinations that have more than one predecessor. This latter issue is a problem because we would like to register outgoing edges along a path in the path solver (regardless of single_pred_p). Committed. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_range_op): Rename postfold_gcond_edges to register_outgoing_edges and adapt. (fold_using_range::postfold_gcond_edges): Rename... (fur_source::register_outgoing_edges): ...to this. * gimple-range-fold.h (postfold_gcond_edges): Rename to register_outgoing_edges and move to fur_source. --- gcc/gimple-range-fold.cc | 44 ++++++++++++++++++++-------------------- gcc/gimple-range-fold.h | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 4dbf4188ec2..921e8e3388f 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -651,7 +651,17 @@ fold_using_range::range_of_range_op (irange &r, gimple *s, fur_source &src) } } else if (is_a (s)) - postfold_gcond_edges (as_a (s), r, src); + { + basic_block bb = gimple_bb (s); + edge e0 = EDGE_SUCC (bb, 0); + edge e1 = EDGE_SUCC (bb, 1); + + if (!single_pred_p (e0->dest)) + e0 = NULL; + if (!single_pred_p (e1->dest)) + e1 = NULL; + src.register_outgoing_edges (as_a (s), r, e0, e1); + } } else r.set_varying (type); @@ -1353,8 +1363,7 @@ fold_using_range::relation_fold_and_or (irange& lhs_range, gimple *s, // Register any outgoing edge relations from a conditional branch. void -fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, - fur_source &src) +fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge e1) { int_range_max r; int_range<2> e0_range, e1_range; @@ -1366,10 +1375,7 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, if (!bb) return; - edge e0 = EDGE_SUCC (bb, 0); - if (!single_pred_p (e0->dest)) - e0 = NULL; - else + if (e0) { // If this edge is never taken, ignore it. gcond_edge_range (e0_range, e0); @@ -1379,10 +1385,7 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, } - edge e1 = EDGE_SUCC (bb, 1); - if (!single_pred_p (e1->dest)) - e1 = NULL; - else + if (e1) { // If this edge is never taken, ignore it. gcond_edge_range (e1_range, e1); @@ -1391,7 +1394,6 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, e1 = NULL; } - // At least one edge needs to be single pred. if (!e0 && !e1) return; @@ -1407,27 +1409,25 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, { relation_kind relation = handler->op1_op2_relation (e0_range); if (relation != VREL_NONE) - src.register_relation (e0, relation, ssa1, ssa2); + register_relation (e0, relation, ssa1, ssa2); } if (e1) { relation_kind relation = handler->op1_op2_relation (e1_range); if (relation != VREL_NONE) - src.register_relation (e1, relation, ssa1, ssa2); + register_relation (e1, relation, ssa1, ssa2); } } // Outgoing relations of GORI exports require a gori engine. - if (!src.gori ()) + if (!gori ()) return; - range_query *q = src.query (); // Now look for other relations in the exports. This will find stmts // leading to the condition such as: // c_2 = a_4 < b_7 // if (c_2) - - FOR_EACH_GORI_EXPORT_NAME (*(src.gori ()), bb, name) + FOR_EACH_GORI_EXPORT_NAME (*(gori ()), bb, name) { if (TREE_CODE (TREE_TYPE (name)) != BOOLEAN_TYPE) continue; @@ -1439,19 +1439,19 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (stmt)); if (ssa1 && ssa2) { - if (e0 && src.gori ()->outgoing_edge_range_p (r, e0, name, *q) + if (e0 && gori ()->outgoing_edge_range_p (r, e0, name, *m_query) && r.singleton_p ()) { relation_kind relation = handler->op1_op2_relation (r); if (relation != VREL_NONE) - src.register_relation (e0, relation, ssa1, ssa2); + register_relation (e0, relation, ssa1, ssa2); } - if (e1 && src.gori ()->outgoing_edge_range_p (r, e1, name, *q) + if (e1 && gori ()->outgoing_edge_range_p (r, e1, name, *m_query) && r.singleton_p ()) { relation_kind relation = handler->op1_op2_relation (r); if (relation != VREL_NONE) - src.register_relation (e1, relation, ssa1, ssa2); + register_relation (e1, relation, ssa1, ssa2); } } } diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h index ceed7ba48e1..d62d29b7133 100644 --- a/gcc/gimple-range-fold.h +++ b/gcc/gimple-range-fold.h @@ -129,6 +129,7 @@ public: tree op2); virtual void register_relation (edge e, relation_kind k, tree op1, tree op2); + void register_outgoing_edges (gcond *, irange &lhs_range, edge e0, edge e1); protected: range_query *m_query; gori_compute *m_gori; @@ -188,6 +189,5 @@ protected: void range_of_ssa_name_with_loop_info (irange &, tree, class loop *, gphi *, fur_source &src); void relation_fold_and_or (irange& lhs_range, gimple *s, fur_source &src); - void postfold_gcond_edges (gcond *s, irange &lhs_range, fur_source &src); }; #endif // GCC_GIMPLE_RANGE_FOLD_H