From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 D18EA398B855 for ; Fri, 21 May 2021 11:52:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D18EA398B855 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-231-WmFQ6BjaO4u_VInbw6DQSw-1; Fri, 21 May 2021 07:52:37 -0400 X-MC-Unique: WmFQ6BjaO4u_VInbw6DQSw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9476801817; Fri, 21 May 2021 11:52:36 +0000 (UTC) Received: from abulafia.quesejoda.com (ovpn-113-127.ams2.redhat.com [10.36.113.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6797D5D9D5; Fri, 21 May 2021 11:52:36 +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 14LBqYgM1148432 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 May 2021 13:52:34 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 14LBqYdC1148431; Fri, 21 May 2021 13:52:34 +0200 From: Aldy Hernandez To: GCC patches , Andrew MacLeod Cc: Jeff Law , Martin Sebor , Aldy Hernandez Subject: [PATCH 5/5] Cleanup get_range_info Date: Fri, 21 May 2021 13:39:54 +0200 Message-Id: <20210521113954.1148075-5-aldyh@redhat.com> In-Reply-To: <20210521113954.1148075-1-aldyh@redhat.com> References: <20210521113954.1148075-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Fri, 21 May 2021 11:52:41 -0000 Now that there is only one user of get_range_info() we can clean this up to always return a range instead of pairs of wide_ints. A follow-up patch will inline both get_range_info and get_ptr_nonnull into its only remaining user. Tested on x86-64 Linux. OK? gcc/ChangeLog: * tree-ssanames.c (get_range_info): Merge both copies of get_range_info into one that works with irange. * tree-ssanames.h (get_range_info): Remove version that works on wide_ints. --- gcc/tree-ssanames.c | 57 +++++++++++---------------------------------- gcc/tree-ssanames.h | 2 -- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 51a26d2fce1..5329c0a4187 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -423,58 +423,29 @@ set_range_info (tree name, const value_range &vr) set_range_info (name, vr.kind (), min, max); } -/* Gets range information MIN, MAX and returns enum value_range_kind - corresponding to tree ssa_name NAME. enum value_range_kind returned - is used to determine if MIN and MAX are valid values. */ +/* Gets range information corresponding to ssa_name NAME and stores it + in a value_range VR. Returns the value_range_kind. */ enum value_range_kind -get_range_info (const_tree expr, wide_int *min, wide_int *max) +get_range_info (const_tree name, irange &vr) { - gcc_assert (!POINTER_TYPE_P (TREE_TYPE (expr))); - gcc_assert (min && max); - if (TREE_CODE (expr) == INTEGER_CST) - { - *min = wi::to_wide (expr); - *max = *min; - return VR_RANGE; - } - if (TREE_CODE (expr) != SSA_NAME) - return VR_VARYING; + tree type = TREE_TYPE (name); + gcc_checking_assert (!POINTER_TYPE_P (type)); + gcc_checking_assert (TREE_CODE (name) == SSA_NAME); - range_info_def *ri = SSA_NAME_RANGE_INFO (expr); + range_info_def *ri = SSA_NAME_RANGE_INFO (name); /* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision. */ - if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr))) + if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (name))) > 2 * HOST_BITS_PER_WIDE_INT)) - return VR_VARYING; - - *min = ri->get_min (); - *max = ri->get_max (); - return SSA_NAME_RANGE_TYPE (expr); -} - -/* Gets range information corresponding to ssa_name NAME and stores it - in a value_range VR. Returns the value_range_kind. */ - -enum value_range_kind -get_range_info (const_tree name, irange &vr) -{ - tree min, max; - wide_int wmin, wmax; - enum value_range_kind kind = get_range_info (name, &wmin, &wmax); - - if (kind == VR_VARYING) - vr.set_varying (TREE_TYPE (name)); - else if (kind == VR_UNDEFINED) - vr.set_undefined (); + vr.set_varying (type); else - { - min = wide_int_to_tree (TREE_TYPE (name), wmin); - max = wide_int_to_tree (TREE_TYPE (name), wmax); - vr.set (min, max, kind); - } - return kind; + vr.set (wide_int_to_tree (type, ri->get_min ()), + wide_int_to_tree (type, ri->get_max ()), + SSA_NAME_RANGE_TYPE (name)); + + return vr.kind (); } /* Set nonnull attribute to pointer NAME. */ diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index cce2d2c22e8..166f921f04c 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -71,8 +71,6 @@ extern void set_range_info (tree, enum value_range_kind, const wide_int_ref &, const wide_int_ref &); extern void set_range_info (tree, const value_range &); /* Gets the value range from SSA. */ -extern enum value_range_kind get_range_info (const_tree, wide_int *, - wide_int *); extern enum value_range_kind get_range_info (const_tree, irange &); extern void set_nonzero_bits (tree, const wide_int_ref &); extern wide_int get_nonzero_bits (const_tree); -- 2.31.1