From patchwork Sat May 4 08:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1931251 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=h/8oJlHI; 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 4VWgzJ0Gkrz1ybC for ; Sat, 4 May 2024 18:37:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 393FE3844775 for ; Sat, 4 May 2024 08:37:46 +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 B3A243844778 for ; Sat, 4 May 2024 08:31:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3A243844778 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 B3A243844778 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=1714811474; cv=none; b=iBlWLDeSv0sBAKuTGtchW5xf6uZlu80OWGlcefLOuP52gTAOCqaAj4Bn2DsBBImwAHBEfdtLO6Do0PbzTweTdFZaZ6Ksxb4ry3URX+FpdUQpABBqipFeW1fPuLkSaXXQa0NlqmGLo1yBuxApjko9k1FJFupxg3d+QN6Wz/UEqxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714811474; c=relaxed/simple; bh=8png+dRwMqmOwdqswstJvZ37L6IArMNyRnlonTBAXys=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AZXtW5Ls84TFt/lks3s1K9x7zWfcXyNYUkIzx702lph5EKxfLbx3Cn/NFOIZmwO8nPMG+GJlpG5lzDwGtkJbUT9fp4RqmJOQA0KFq3+0gg7i54T5hOSDbGT7Nx9oWQQduEZlwiE5xqhTAXPg1Ldp0AcwpKMAIMwbHv+k9mPNpl8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714811464; 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=Wpv8erdXgpXNbla/Pv0tmVBfI8bxSFYWDhiNqEZDevc=; b=h/8oJlHICmyxUwlBeUa0jpw2X4+KsorV/aupf3235Se5ZotRcq+n/UJ11+U+pA4ucl/15L ULOKDNLzul8570k5AmP8rj6LXcC0ygE4KIhc+Q0i2Z/2lSw4dIFhRN4uAI5ayrX9Klo4dk 9HhaCpsYk74ccaqda4GhPTg3FWXYMlI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-5vfYP65TP4K4H9qBEEGGnQ-1; Sat, 04 May 2024 04:31:02 -0400 X-MC-Unique: 5vfYP65TP4K4H9qBEEGGnQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 32E518943A2 for ; Sat, 4 May 2024 08:31:02 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E28F820296D3; 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 4448V0rD139840 (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 4448V0ha139839; Sat, 4 May 2024 10:31:00 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED 14/23] Implement operator_pointer_diff for prange. Date: Sat, 4 May 2024 10:30:42 +0200 Message-ID: <20240504083056.139719-15-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.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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-ptr.cc (operator_pointer_diff::op1_op2_relation_effect): New. (operator_pointer_diff::pointers_handled_p): New. --- gcc/range-op-ptr.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index a4418215613..b90b8bb9f65 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -564,10 +564,42 @@ class operator_pointer_diff : public range_operator const irange &op1_range, const irange &op2_range, relation_kind rel) const; + virtual bool op1_op2_relation_effect (irange &lhs_range, + tree type, + const prange &op1_range, + const prange &op2_range, + relation_kind rel) const final override; void update_bitmask (irange &r, const irange &lh, const irange &rh) const { update_known_bitmask (r, POINTER_DIFF_EXPR, lh, rh); } + void update_bitmask (irange &r, + const prange &lh, const prange &rh) const final override + { update_known_bitmask (r, POINTER_DIFF_EXPR, lh, rh); } + bool pointers_handled_p (range_op_dispatch_type, unsigned) const final override; } op_pointer_diff; +bool +operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, + const prange &op1_range, + const prange &op2_range, + relation_kind rel) const +{ + int_range<2> op1, op2, tmp; + range_op_handler cast (CONVERT_EXPR); + + if (!cast.fold_range (op1, type, op1_range, tmp) + || !cast.fold_range (op2, type, op2_range, tmp)) + return false; + + return minus_op1_op2_relation_effect (lhs_range, type, op1, op2, rel); +} + +bool +operator_pointer_diff::pointers_handled_p (range_op_dispatch_type, + unsigned) const +{ + return true; +} + bool operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, const irange &op1_range,