From patchwork Sun Apr 28 19:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1928689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DrZicyjh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VSGFd50PDz23t4 for ; Mon, 29 Apr 2024 05:08:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00AAD38449C0 for ; Sun, 28 Apr 2024 19:08:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by sourceware.org (Postfix) with ESMTPS id A33CD385840E for ; Sun, 28 Apr 2024 19:06:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A33CD385840E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=localhost.redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A33CD385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331171; cv=none; b=l7EaCH70V7GW9ykQGjZb7TlrcIvvgHzC/96hw1wx/IE1/4RP7+fuDhXRklnY6548XFLCiKeJF5dAekUgxktfQ4YmqIlQFLUmW76Xfs3m5sLQxcWp4cbMuy4kfgozWYlS/O+rzkzkdTASrw4j9AZ7q6WlL7bhczUnmA2H2eoEASo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714331171; c=relaxed/simple; bh=ceOAYh55qo5UxDzKtUh6i6aKp+iQVndV2EBbcHFMUSs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hrfmd0PauOl1A9xQJrTbLYh1zNOX88+rZfRNHa8dnzatIPAGoMVAv7BAUBhPb4rKfqdqXo7jtEW8SoC90HOMxIOwiNiZHTDPPUVZn2itdw5F5aJlIbH5QtCpu3Dl0uBS9zeK0Y9R0H7gNO5otX48ZbieUePFQx+jpKezRFXbFDs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714331166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HwGV2kF8YUFBm1JIQVhpOiIJZpsocAc9e4BY64T3aXM=; b=DrZicyjhLS03e5RxhJDfSSpRvSHtl7N9dqxPy4WgGgaWYp5xVuntjpd1T5iDUzHQwILRy7 nDk7+M0tm+GVooe9Utddahsg8OB2xWsrwGpD3odRCcaD0w0E1n8x4n8u3oBW+wpfdzI3Sg M/7oqUzYyAvW49t+/jF2DFCUXdPOVEs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-OIXSpPL8NQ6P6tHkwz7c8w-1; Sun, 28 Apr 2024 15:06:02 -0400 X-MC-Unique: OIXSpPL8NQ6P6tHkwz7c8w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6C1D38000A9 for ; Sun, 28 Apr 2024 19:06:02 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 643B2EC680; Sun, 28 Apr 2024 19:06:02 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.2/8.17.1) with ESMTPS id 43SJ61rp1209676 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 28 Apr 2024 21:06:01 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.2/8.17.2/Submit) id 43SJ61OX1209675; Sun, 28 Apr 2024 21:06:01 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED 10/16] Accept a vrange in get_legacy_range. Date: Sun, 28 Apr 2024 21:05:48 +0200 Message-ID: <20240428190557.1209586-11-aldyh@redhat.com> In-Reply-To: <20240428190557.1209586-1-aldyh@redhat.com> References: <20240428190557.1209586-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org In preparation for prange, make get_legacy_range take a generic vrange, not just an irange. gcc/ChangeLog: * value-range.cc (get_legacy_range): Make static and add another version of get_legacy_range that takes a vrange. * value-range.h (class irange): Remove unnecessary friendship with get_legacy_range. (get_legacy_range): Accept a vrange. --- gcc/value-range.cc | 17 ++++++++++++++++- gcc/value-range.h | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index b901c864a7b..44929b210aa 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1004,7 +1004,7 @@ irange::operator= (const irange &src) return *this; } -value_range_kind +static value_range_kind get_legacy_range (const irange &r, tree &min, tree &max) { if (r.undefined_p ()) @@ -1041,6 +1041,21 @@ get_legacy_range (const irange &r, tree &min, tree &max) return VR_RANGE; } +// Given a range in V, return an old-style legacy range consisting of +// a value_range_kind with a MIN/MAX. This is to maintain +// compatibility with passes that still depend on VR_ANTI_RANGE, and +// only works for integers and pointers. + +value_range_kind +get_legacy_range (const vrange &v, tree &min, tree &max) +{ + if (is_a (v)) + return get_legacy_range (as_a (v), min, max); + + gcc_unreachable (); + return VR_UNDEFINED; +} + /* Set value range to the canonical form of {VRTYPE, MIN, MAX, EQUIV}. This means adjusting VRTYPE, MIN and MAX representing the case of a wrapping range with MAX < MIN covering [MIN, type_max] U [type_min, MAX] diff --git a/gcc/value-range.h b/gcc/value-range.h index 62f123e2a4b..d2e8fd5a4d9 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -281,7 +281,6 @@ irange_bitmask::intersect (const irange_bitmask &orig_src) class irange : public vrange { - friend value_range_kind get_legacy_range (const irange &, tree &, tree &); friend class irange_storage; friend class vrange_printer; public: @@ -886,7 +885,7 @@ Value_Range::supports_type_p (const_tree type) return irange::supports_p (type) || frange::supports_p (type); } -extern value_range_kind get_legacy_range (const irange &, tree &min, tree &max); +extern value_range_kind get_legacy_range (const vrange &, tree &min, tree &max); extern void dump_value_range (FILE *, const vrange *); extern bool vrp_operand_equal_p (const_tree, const_tree); inline REAL_VALUE_TYPE frange_val_min (const_tree type);