From patchwork Tue Nov 22 13:58:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 60979 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 0AAC0384F6DF for ; Tue, 22 Nov 2022 13:58:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AAC0384F6DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669125535; bh=SO/SZ9lG0WmkN2xm4UqXQREdTZP9YsWWTsNKFA40lQU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=OhFsHatWfdtROXh2B3pNmYb3X0KetaZq4qejYIbXtWRU2sce27PBmgWeSKarw+JgY CxVyWwPd6+ANUwV6+jY+IpF6qgrAFUHp+QTXZwFR+HFcOUAmfurmd3KoqoZg8OfxNM 8XqqOmPhKbxHZeZxTxB+AWnFKARlNGMdM5sZJnq8= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 00F3A3858412 for ; Tue, 22 Nov 2022 13:58:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00F3A3858412 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-lJqYkpTiPRmpD18tgppfvQ-1; Tue, 22 Nov 2022 08:58:15 -0500 X-MC-Unique: lJqYkpTiPRmpD18tgppfvQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 272D829DD985; Tue, 22 Nov 2022 13:58:15 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.203]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C84521731B; Tue, 22 Nov 2022 13:58:14 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 2AMDwBXX1945506 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 14:58:11 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 2AMDwBTG1945505; Tue, 22 Nov 2022 14:58:11 +0100 To: Richard Biener Cc: GCC patches , Andrew MacLeod , Aldy Hernandez Subject: [PATCH] Remove follow_assert_exprs from overflow_comparison. Date: Tue, 22 Nov 2022 14:58:00 +0100 Message-Id: <20221122135801.1945438-2-aldyh@redhat.com> In-Reply-To: <20221122135801.1945438-1-aldyh@redhat.com> References: <20221122135801.1945438-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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" OK pending tests? gcc/ChangeLog: * tree-vrp.cc (overflow_comparison_p_1): Remove follow_assert_exprs. (overflow_comparison_p): Remove use_equiv_p. * tree-vrp.h (overflow_comparison_p): Same. * vr-values.cc (vrp_evaluate_conditional_warnv_with_ops): Remove use_equiv_p argument to overflow_comparison_p. --- gcc/tree-vrp.cc | 40 ++++------------------------------------ gcc/tree-vrp.h | 2 +- gcc/vr-values.cc | 2 +- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index d29941d0f2d..3846dc1d849 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -679,7 +679,7 @@ range_fold_unary_expr (value_range *vr, static bool overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, - bool follow_assert_exprs, bool reversed, tree *new_cst) + bool reversed, tree *new_cst) { /* See if this is a relational operation between two SSA_NAMES with unsigned, overflow wrapping values. If so, check it more deeply. */ @@ -693,19 +693,6 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, { gimple *op1_def = SSA_NAME_DEF_STMT (op1); - /* If requested, follow any ASSERT_EXPRs backwards for OP1. */ - if (follow_assert_exprs) - { - while (gimple_assign_single_p (op1_def) - && TREE_CODE (gimple_assign_rhs1 (op1_def)) == ASSERT_EXPR) - { - op1 = TREE_OPERAND (gimple_assign_rhs1 (op1_def), 0); - if (TREE_CODE (op1) != SSA_NAME) - break; - op1_def = SSA_NAME_DEF_STMT (op1); - } - } - /* Now look at the defining statement of OP1 to see if it adds or subtracts a nonzero constant from another operand. */ if (op1_def @@ -716,24 +703,6 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, { tree target = gimple_assign_rhs1 (op1_def); - /* If requested, follow ASSERT_EXPRs backwards for op0 looking - for one where TARGET appears on the RHS. */ - if (follow_assert_exprs) - { - /* Now see if that "other operand" is op0, following the chain - of ASSERT_EXPRs if necessary. */ - gimple *op0_def = SSA_NAME_DEF_STMT (op0); - while (op0 != target - && gimple_assign_single_p (op0_def) - && TREE_CODE (gimple_assign_rhs1 (op0_def)) == ASSERT_EXPR) - { - op0 = TREE_OPERAND (gimple_assign_rhs1 (op0_def), 0); - if (TREE_CODE (op0) != SSA_NAME) - break; - op0_def = SSA_NAME_DEF_STMT (op0); - } - } - /* If we did not find our target SSA_NAME, then this is not an overflow test. */ if (op0 != target) @@ -764,13 +733,12 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, the alternate range representation is often useful within VRP. */ bool -overflow_comparison_p (tree_code code, tree name, tree val, - bool use_equiv_p, tree *new_cst) +overflow_comparison_p (tree_code code, tree name, tree val, tree *new_cst) { - if (overflow_comparison_p_1 (code, name, val, use_equiv_p, false, new_cst)) + if (overflow_comparison_p_1 (code, name, val, false, new_cst)) return true; return overflow_comparison_p_1 (swap_tree_comparison (code), val, name, - use_equiv_p, true, new_cst); + true, new_cst); } /* Handle diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 07630b5b1ca..127909604f0 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -39,7 +39,7 @@ extern enum value_range_kind intersect_range_with_nonzero_bits extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *); extern tree find_case_label_range (gswitch *, const irange *vr); extern bool find_case_label_index (gswitch *, size_t, tree, size_t *); -extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *); +extern bool overflow_comparison_p (tree_code, tree, tree, tree *); extern void maybe_set_nonzero_bits (edge, tree); #endif /* GCC_TREE_VRP_H */ diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 0347c29b216..b0dd30260ae 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -837,7 +837,7 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops occurs when the chosen argument is zero and does not occur if the chosen argument is not zero. */ tree x; - if (overflow_comparison_p (code, op0, op1, use_equiv_p, &x)) + if (overflow_comparison_p (code, op0, op1, &x)) { wide_int max = wi::max_value (TYPE_PRECISION (TREE_TYPE (op0)), UNSIGNED); /* B = A - 1; if (A < B) -> B = A - 1; if (A == 0)