From patchwork Tue Nov 22 13:58:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 24390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2212482wrr; Tue, 22 Nov 2022 05:59:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5wR1qFj7emP5vrnXJmYU4YkNAQNN3znQVlMFKKSKFeB/oDyUnark9bzWbtDxuNMpMcSQFN X-Received: by 2002:a05:6402:4289:b0:467:9864:9463 with SMTP id g9-20020a056402428900b0046798649463mr4355438edc.360.1669125576749; Tue, 22 Nov 2022 05:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669125576; cv=none; d=google.com; s=arc-20160816; b=QAMINn4ZtKWZiUB3n2gsT61ns3kr3Dv1z8PdGEphvfQVNuAL+IP2IV9ANd2dDZ6SxK y2ayynxSeXai0Ga0TwTCKoBkNpdrLAZoOsmwdfrEcZlzoKaVl/5ZnmKk8Rks4B5CbMk1 ktvX3KsPSMXTyIpRPBVcr1ksxEklpDSKKeEw9Pgk3GC3zVy+m/ITaR0vIMs5wbtvH5Jp cBSu0MeGI+00aNVYmmzWNXEkZCD3eISQzjTBtUXBZ9bAYokhEgxKVf7NgIaJR18EAwEq 3z2jcFfqCfFcVN3T2PPCrJlARREHFvHB3mh6uf8em/69Y/DlPq1XhliVEa1nLDJktwVX /Piw== 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=oXCzFh4OS+zUmogAAQOXtCTVr971Jz7rebeukUR/lPE=; b=UxbJ0To6ypCEeZskUFbdsSo9D/cbxoNKHKTlCnO7rfYcRA6tzo6wItSGWHzm2CSoUK DgVQuqcI+g7exEUWklymISkE5w5v0z4Xb7fs8+Zp9y4XY/fSwgOchnMSVmbjrq8vW0mi j6cwKdxDLssfHABVjAr0SBVowGFhX/nsim3Yvau5MpIyRMbV4RXCgpbpQNdUO8ZIAqro yddAm3k/2+XtXPtQVz460Tsqg6lEjWo0OME9oMNxCeSGBJe4HxcyNPCLZeYPPpXGjXDN bwboR3SQjVe4hkde01KIEt9lcTKUsVT+qSn5xw9Uj8wCp2VChp3HqNVrOuX0qoDeqhed shYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vReOimsp; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z2-20020a1709063ac200b007ae0fe6198fsi1455540ejd.132.2022.11.22.05.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 05:59:36 -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=vReOimsp; 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 6D4E13853D45 for ; Tue, 22 Nov 2022 13:59:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D4E13853D45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669125546; bh=oXCzFh4OS+zUmogAAQOXtCTVr971Jz7rebeukUR/lPE=; 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=vReOimspmuUoXmWbkwZxOKEy9tURrVG5X5NLNgKu6/kLLEWMUi2upfRKb7qEHAHoz wVQFrx5JVTkDBhHJxQPP8U7hBaFjaP+cMrrI78HjmsBtjec/ITol3eQQdhBZt0dG+S OEwxJl2ZX07HS6azOWkkJmoee0D7sWRdISpdsojM= 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 ESMTPS id 98AC43858430 for ; Tue, 22 Nov 2022 13:58:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98AC43858430 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-IDeojqrMOyqGd0EJX7FQ1g-1; Tue, 22 Nov 2022 08:58:18 -0500 X-MC-Unique: IDeojqrMOyqGd0EJX7FQ1g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F006C8032E6; Tue, 22 Nov 2022 13:58:17 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.203]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9ABE640C6EC6; Tue, 22 Nov 2022 13:58:17 +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 2AMDwCVJ1945510 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 22 Nov 2022 14:58:12 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 2AMDwCTS1945509; Tue, 22 Nov 2022 14:58:12 +0100 To: Richard Biener Cc: GCC patches , Andrew MacLeod , Aldy Hernandez Subject: [PATCH] Remove use_equiv_p in vr-values.cc Date: Tue, 22 Nov 2022 14:58:01 +0100 Message-Id: <20221122135801.1945438-3-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.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 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.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?1750205020921204953?= X-GMAIL-MSGID: =?utf-8?q?1750205020921204953?= With no equivalences, the use_equiv_p argument in various methods in simplify_using_ranges is always false. This means we can remove all calls to compare_names, along with the function. OK pending tests? gcc/ChangeLog: * vr-values.cc (simplify_using_ranges::compare_names): Remove. (vrp_evaluate_conditional_warnv_with_ops): Remove call to compare_names. (simplify_using_ranges::vrp_visit_cond_stmt): Remove use_equiv_p argument to vrp_evaluate_conditional_warnv_with_ops. * vr-values.h (class simplify_using_ranges): Remove compare_names. Remove use_equiv_p to vrp_evaluate_conditional_warnv_with_ops. --- gcc/vr-values.cc | 127 +---------------------------------------------- gcc/vr-values.h | 4 +- 2 files changed, 3 insertions(+), 128 deletions(-) diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index b0dd30260ae..1dbd9e47085 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -667,124 +667,6 @@ simplify_using_ranges::compare_name_with_value return retval; } -/* Given a comparison code COMP and names N1 and N2, compare all the - ranges equivalent to N1 against all the ranges equivalent to N2 - to determine the value of N1 COMP N2. Return the same value - returned by compare_ranges. Set *STRICT_OVERFLOW_P to indicate - whether we relied on undefined signed overflow in the comparison. */ - - -tree -simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, - bool *strict_overflow_p, gimple *s) -{ - /* ?? These bitmaps are NULL as there are no longer any equivalences - available in the value_range*. */ - bitmap e1 = NULL; - bitmap e2 = NULL; - - /* Use the fake bitmaps if e1 or e2 are not available. */ - static bitmap s_e1 = NULL, s_e2 = NULL; - static bitmap_obstack *s_obstack = NULL; - if (s_obstack == NULL) - { - s_obstack = XNEW (bitmap_obstack); - bitmap_obstack_initialize (s_obstack); - s_e1 = BITMAP_ALLOC (s_obstack); - s_e2 = BITMAP_ALLOC (s_obstack); - } - if (e1 == NULL) - e1 = s_e1; - if (e2 == NULL) - e2 = s_e2; - - /* Add N1 and N2 to their own set of equivalences to avoid - duplicating the body of the loop just to check N1 and N2 - ranges. */ - bitmap_set_bit (e1, SSA_NAME_VERSION (n1)); - bitmap_set_bit (e2, SSA_NAME_VERSION (n2)); - - /* If the equivalence sets have a common intersection, then the two - names can be compared without checking their ranges. */ - if (bitmap_intersect_p (e1, e2)) - { - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); - - return (comp == EQ_EXPR || comp == GE_EXPR || comp == LE_EXPR) - ? boolean_true_node - : boolean_false_node; - } - - /* Start at -1. Set it to 0 if we do a comparison without relying - on overflow, or 1 if all comparisons rely on overflow. */ - int used_strict_overflow = -1; - - /* Otherwise, compare all the equivalent ranges. First, add N1 and - N2 to their own set of equivalences to avoid duplicating the body - of the loop just to check N1 and N2 ranges. */ - bitmap_iterator bi1; - unsigned i1; - EXECUTE_IF_SET_IN_BITMAP (e1, 0, i1, bi1) - { - if (!ssa_name (i1)) - continue; - - value_range tem_vr1; - const value_range *vr1 = get_vr_for_comparison (i1, &tem_vr1, s); - - tree t = NULL_TREE, retval = NULL_TREE; - bitmap_iterator bi2; - unsigned i2; - EXECUTE_IF_SET_IN_BITMAP (e2, 0, i2, bi2) - { - if (!ssa_name (i2)) - continue; - - bool sop = false; - - value_range tem_vr2; - const value_range *vr2 = get_vr_for_comparison (i2, &tem_vr2, s); - - t = compare_ranges (comp, vr1, vr2, &sop); - if (t) - { - /* If we get different answers from different members - of the equivalence set this check must be in a dead - code region. Folding it to a trap representation - would be correct here. For now just return don't-know. */ - if (retval != NULL && t != retval) - { - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); - return NULL_TREE; - } - retval = t; - - if (!sop) - used_strict_overflow = 0; - else if (used_strict_overflow < 0) - used_strict_overflow = 1; - } - } - - if (retval) - { - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); - if (used_strict_overflow > 0) - *strict_overflow_p = true; - return retval; - } - } - - /* None of the equivalent ranges are useful in computing this - comparison. */ - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); - return NULL_TREE; -} - /* Helper function for vrp_evaluate_conditional_warnv & other optimizers. */ @@ -815,7 +697,6 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops (gimple *stmt, enum tree_code code, tree op0, tree op1, - bool use_equiv_p, bool *strict_overflow_p, bool *only_ranges) { @@ -899,11 +780,7 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops return ret; if (only_ranges) *only_ranges = false; - /* Do not use compare_names during propagation, it's quadratic. */ - if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME - && use_equiv_p) - return compare_names (code, op0, op1, strict_overflow_p, stmt); - else if (TREE_CODE (op0) == SSA_NAME) + if (TREE_CODE (op0) == SSA_NAME) return compare_name_with_value (code, op0, op1, strict_overflow_p, stmt); else if (TREE_CODE (op1) == SSA_NAME) return compare_name_with_value (swap_tree_comparison (code), op1, op0, @@ -949,7 +826,7 @@ simplify_using_ranges::vrp_visit_cond_stmt (gcond *stmt, edge *taken_edge_p) gimple_cond_code (stmt), gimple_cond_lhs (stmt), gimple_cond_rhs (stmt), - false, &sop, NULL); + &sop, NULL); if (val) *taken_edge_p = find_taken_edge (gimple_bb (stmt), val); diff --git a/gcc/vr-values.h b/gcc/vr-values.h index 9804aaf83d1..6ad9fb2b81d 100644 --- a/gcc/vr-values.h +++ b/gcc/vr-values.h @@ -37,8 +37,7 @@ public: private: void vrp_visit_cond_stmt (gcond *, edge *); tree vrp_evaluate_conditional_warnv_with_ops (gimple *stmt, enum tree_code, - tree, tree, bool, - bool *, bool *); + tree, tree, bool *, bool *); bool simplify_casted_cond (gcond *); bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *); bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *); @@ -54,7 +53,6 @@ private: bool two_valued_val_range_p (tree, tree *, tree *, gimple *); bool op_with_boolean_value_range_p (tree, gimple *); tree compare_name_with_value (enum tree_code, tree, tree, bool *, gimple *); - tree compare_names (enum tree_code, tree, tree, bool *, gimple *s); const value_range *get_vr_for_comparison (int, value_range *, gimple *s); tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code, tree, tree,