From patchwork Sat May 4 08:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1931242 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=MsA+qWmX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4VWgvB5XMCz1xnS for ; Sat, 4 May 2024 18:34:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0914386F43B for ; Sat, 4 May 2024 08:34:12 +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 [207.211.30.44]) by sourceware.org (Postfix) with ESMTPS id F1EE43844755 for ; Sat, 4 May 2024 08:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F1EE43844755 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 F1EE43844755 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714811467; cv=none; b=LrWhJcJtvgwmvf2dhmUf1f6NnnYuTU9kPzEILSjiHlXLII7xpVAunaOboH5pSElRPTcCBCS4g5Y9mhsldFtelKmSlSz6N4L1Z8A6UWOfJVcz3Zs/ji7YtL1ERAWjxsGXYpU2ATLGXSoJRPakrLpckTv3COO25x8StbLblDGSS1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714811467; c=relaxed/simple; bh=5evlB9xbPlzM9T2wHpkrpbpeAL+xGwOnscrjMayEjOU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SCB5gCXTZsDR+xAzXDjops7kq4T0nvE33X0ln2gs4V7Mjgu4XrNKCBYrNgqVIJo6MLjc6SD1TggJasZ13/qdZeLJ7IwyGj50r92BLtlI0AXtRZHP7v+BGraGzJucDukew3jz5D52DcpJPEt+vl7yhmt9pwVaSM+Ze66VpBxgitI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714811463; 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=y7qqdTwpbPnczU65Hao0bSxo5p8dvtVGcxmfLfAEpfQ=; b=MsA+qWmXlbAjllT/p0h3GZVPdVBQeb127LP6xAC6cFQFnmruHdmqKyLIxjGiAxbw82LW+5 LW8mnIzJWGyPIsfTz9aVxYPSbpRAfYnlwrhJ0CB8tYsrhPhdzPKlt59ZqSoF7n8YfpSgsP gAHnXc5JrTmw/PzqlwFdM6Gej9K1ahc= 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-493-XFDHywbsONOEE7Q9vCq0iA-1; Sat, 04 May 2024 04:31:02 -0400 X-MC-Unique: XFDHywbsONOEE7Q9vCq0iA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 D2A213806700 for ; Sat, 4 May 2024 08:31:01 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F461400EAE; Sat, 4 May 2024 08:31:01 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.18.1/8.17.1) with ESMTPS id 4448V0YD139832 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 4 May 2024 10:31:00 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.18.1/8.18.1/Submit) id 4448V0LB139831; Sat, 4 May 2024 10:31:00 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED 12/23] Implement operator_addr_expr for prange. Date: Sat, 4 May 2024 10:30:40 +0200 Message-ID: <20240504083056.139719-13-aldyh@redhat.com> In-Reply-To: <20240504083056.139719-1-aldyh@redhat.com> References: <20240504083056.139719-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 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 gcc/ChangeLog: * range-op-mixed.h: Add overloaded declarations for pointer variants. * range-op-ptr.cc (operator_addr_expr::op1_range): New. (operator_addr_expr::pointers_handled_p): New. --- gcc/range-op-mixed.h | 4 ++++ gcc/range-op-ptr.cc | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index b69e674a78b..0df300781f1 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -655,6 +655,10 @@ public: bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, relation_trio rel = TRIO_VARYING) const final override; + bool op1_range (prange &r, tree type, + const prange &lhs, const prange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override; }; class operator_bitwise_not : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 0addd1096c2..38d9f65566f 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -1021,6 +1021,44 @@ operator_max::pointers_handled_p (range_op_dispatch_type type, } } +bool +operator_addr_expr::op1_range (prange &r, tree type, + const prange &lhs, + const prange &op2, + relation_trio) const +{ + if (empty_range_varying (r, type, lhs, op2)) + return true; + + // Return a non-null pointer of the LHS type (passed in op2), but only + // if we cant overflow, eitherwise a no-zero offset could wrap to zero. + // See PR 111009. + if (!lhs.undefined_p () + && !range_includes_zero_p (lhs) + && TYPE_OVERFLOW_UNDEFINED (type)) + r.set_nonzero (type); + else + r.set_varying (type); + return true; +} + +bool +operator_addr_expr::pointers_handled_p (range_op_dispatch_type type, + unsigned dispatch) const +{ + switch (type) + { + case DISPATCH_FOLD_RANGE: + // NOTE: It looks like we never generate this combination. + gcc_unreachable (); + return false; + case DISPATCH_OP1_RANGE: + return dispatch == RO_PPP; + default: + return true; + } +} + // Initialize any pointer operators to the primary table void