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: 24391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2212535wrr; Tue, 22 Nov 2022 05:59:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gUrMCx6UwMCaSd34+jYCctuPcaGfx9FXCJ5mTwewYgsDoen182gjyVIc0Wq8GJRurbFHm X-Received: by 2002:a05:6402:4445:b0:468:eef6:a83c with SMTP id o5-20020a056402444500b00468eef6a83cmr20701355edb.191.1669125582916; Tue, 22 Nov 2022 05:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669125582; cv=none; d=google.com; s=arc-20160816; b=VGzSOkZUoaoAfnpRpnba4o+Muu06PiwYzcEEe1UsllydUCTDE98JHPSQGSQv7/IHwk IHKQJxmBkZ9YS5FPPbc6GXSxzHoodItjL0xwl4llTN9b7pD17wwn0KkY3TJW1AYrA88w imHyVch/ljns0RYw6O99SNYQRxFAgBoTfWwEhtWdDg8Wk7VRt0GmcViVY4EthqcLNwFz A2L9WRdYYpU5+OhaXxPrv380GOPND2HE+/qNcYNoUTAr0zlHlMcghsfGCAqMxKPK+TqB /RTDX+lJPdcbBQeAfvUnw+7n0hnZLxgjPNjS8IRKHFxks3q9/hY5HDz1K2qb/I2KhmKZ suDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=SO/SZ9lG0WmkN2xm4UqXQREdTZP9YsWWTsNKFA40lQU=; b=de5sd4X8yUxo3fCv5D60tQqvQ+LgOyZH3GS5iPS3rsyQ6rJs9p7uitL+zlwcoOBcm5 IlBoUeFxGSXeShgkT+2lw7jAKt2KSpnVk4sKNz/FbLBnU8ZLpCh4zz8Oh2bQhaOCVHqo POtVFG+JmYEPCyG2Y425MeEWgTN1sgeQ/HbZSeOFszzPgwKfnXW54wgalpeDLC7m3iGP U8P1v0i4OZcn3VvyygkK8RnFtln9m9v+XW9TGLcqHnVwQf6+MUAULXDYTaWDLQwl+N9F jSkMxsUo0rn8OCQiiP85FIXA8uYPckxIKnYtXa+fcjD3U3MS7Vrx5sfa7XcifRFS68xR fKvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LNpA8pAk; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g29-20020a50d5dd000000b0046903099907si9912745edj.275.2022.11.22.05.59.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 05:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LNpA8pAk; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C25D6384F037 for ; Tue, 22 Nov 2022 13:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C25D6384F037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669125549; 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=LNpA8pAks6PGWNEwm6pMJUYS9fE9wmtt57Hcmr9UqmQGL/qdlCnUYCkI7ak7OY/e8 OYKeE5uBzJ2FEd22uEQcTatgYRpwiu9PEXQJH6N0vpy91Da/zkuf6EqNp7YLzV4vMo 7N8ldUsKUR6K+3vllEngm4df6iZLrlY4FkDX3x34= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750205027310670228?= X-GMAIL-MSGID: =?utf-8?q?1750205027310670228?= 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)