From patchwork Thu Oct 24 12:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 2001710 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=BugjnaWh; 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 4XZ5VQ4rhYz1xwy for ; Thu, 24 Oct 2024 23:55:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC6B63858C42 for ; Thu, 24 Oct 2024 12:55:08 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTP id EE8493858D28 for ; Thu, 24 Oct 2024 12:53:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE8493858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EE8493858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729774440; cv=none; b=cREuePHz6iEJ/F2XbQKDqme5FS72hE3sEsNK6BEDLuY2yiXIkp9hBN4IYVyzHlgo8+q3Eu8HQPMpUp1+eI1sTTrGhyBGXViAt0hpl2x5omLxy5mtaPAYmBCiojIqqhXg9fU5DtXW4NgCbDXs9Xfgc4AqUN+IDz3Kee7ti+w1IU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729774440; c=relaxed/simple; bh=4FScQaywZkX0ZN09KSeHXU+l9xPVKSwS3EOwjuRab7w=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=BMVuyTMiXQZgqhV2CRv0pxxaMAGQYwgrXs68fAQMbyFHBDmv80dDEsURJOjt9QShJyqllcGfQzFfiy09GJs64I+yXAGCQwo3sd1PvvMk+Iri5uZw9vRxVxHr3iM1s/hMlcsuCHVKTPbXQ0o1C8nOKocgBfXYpuunRf/UovzspB8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729774434; 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; bh=Y06Olub5qtCm3BuViCbmr1FktDf2UR1Dj3tl0Qu7QXY=; b=BugjnaWhBUZuUzvlPrsXtFZoQ4x+YdoClwtD2laO5SSG5wsmeMbSpuzL8rkWtEIV0Umy4q WMNR/FEdoCFWPtJthX+ARXLj2iTJBSDEDt5uyFVdLsfo+LnfsyC+4uLnUYHrnJ85h9QI5b CRlAQTbCtWLLYKy2Y7Bv3LoSQDy5FU4= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-XZFcm40WOLe37ufx8nmEbw-1; Thu, 24 Oct 2024 08:53:53 -0400 X-MC-Unique: XZFcm40WOLe37ufx8nmEbw-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-460c6731ebeso16155931cf.0 for ; Thu, 24 Oct 2024 05:53:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729774432; x=1730379232; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VBDB8Qf207lk45iqN8/J8qPdhPjqgGg7APvofF64zLk=; b=o3Nq2++zt/q1TLF650IzZShZz2KWvd1RCAXBPv5zRmEaiF3mLGeztOmHkiAbHpZ2bu SqyvBm1fC6Ri9FJ3gbTBh1ACZP9dD5ypNFNgVpEzBYZ3jnXMhp7CAA9VHlnUFpiKEnr4 AMKYx29sjkdmlmFLdjJd4Dg3y6KavCjM7SPz8Ezdrj14to/eYXN/KCcWh2mJT3S01w4G +cV5Roe5J9Z8Gprisouc0efdDqOVmkI67/YyzRgxAXnVFAPwzlzzAUJoL2PLqPhFbQXe BqFQLEamxdNU0mIvm2CM0sYgREv6vIBfriX/Wz/JgNfdEoGNW2cdadq7IFkHtYsQwv/2 oS8Q== X-Gm-Message-State: AOJu0YxFZfK1JR125i646wrucp+AgtTtTxl13h4B5pl81tYHixrd1uWP Kf+HzD2TqXfP/nBvzF1j8f/DpBnSER1DuyqfMzwxOib+9AfqG33/M5mIdCOQSRNOWjzOV1rit1v pdmCNhsTDCtTQrjdz5J+FV/herBUPK80Ul1uNW3nwMij9n6xceqy6p92mm0ZbvLyMC2OStcSc82 L7SpXmULAQQyvMRGjrYZija1205E4U8vaT06ZDMEoQdQ== X-Received: by 2002:a05:622a:3ce:b0:458:3a5a:94a5 with SMTP id d75a77b69052e-461145a9d0dmr82563921cf.2.1729774432163; Thu, 24 Oct 2024 05:53:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+UtvMow94tWOBWPVT+/JG0M5ak3+e0JQmIrjr05BmysIvIgE9ZeC7OPkSx19NStuVQpIDYw== X-Received: by 2002:a05:622a:3ce:b0:458:3a5a:94a5 with SMTP id d75a77b69052e-461145a9d0dmr82563581cf.2.1729774431507; Thu, 24 Oct 2024 05:53:51 -0700 (PDT) Received: from [192.168.0.174] ([104.219.121.80]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-460d3c3b304sm51299721cf.6.2024.10.24.05.53.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Oct 2024 05:53:50 -0700 (PDT) Message-ID: <9ae81606-7e34-423c-b9d5-98147a43d5b6@redhat.com> Date: Thu, 24 Oct 2024 08:53:49 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: aldy@quesejoda.com From: Andrew MacLeod Subject: [COMMITTED 4/4] - Implement pointer_or_operator. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.5 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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 Well, perhaps the subject isn't precise  The existing pointer_or_operator is, like a few others, using irange operands, so is non-functional and this patch removes it. The functionality was never moved to the new dispatch system when Prange was implemented, and IIRC it was because Aldy never found a case that triggered.  Regardless, this adds the functionality that once existed via operator_bitwise_or::fold_range() with Prange operands. Bootstraps on x86_64-pc-linux-gnu with no regressions.  pushed. Andrew From 57f720af635e47d8b5515eddaef9df02769f353b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 23 Oct 2024 10:59:13 -0400 Subject: [PATCH 4/4] Implement pointer_or_operator. The class pointer_or is no longer used, and can be removed. Its functionality was never moved to the new dispatch system. This implements operator_bitwise_or::fold_range() for prange operands. * range-op-mixed.h (operator_bitwise_or::fold_range): Add prange variant. * range-op-ptr.cc (class pointer_or_operator): Remove. (pointer_or_operator::op1_range): Remove. (pointer_or_operator::op2_range): Remove. (pointer_or_operator::wi_fold): Remove. (operator_bitwise_or::fold_range): New prange variant. --- gcc/range-op-mixed.h | 6 +++++ gcc/range-op-ptr.cc | 63 +++++++------------------------------------- 2 files changed, 16 insertions(+), 53 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index cc1db2f6775..f7c447d935e 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -809,9 +809,15 @@ protected: class operator_bitwise_or : public range_operator { public: + using range_operator::fold_range; using range_operator::op1_range; using range_operator::op2_range; using range_operator::update_bitmask; + + bool fold_range (prange &r, tree type, + const prange &op1, + const prange &op2, + relation_trio) const final override; bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, relation_trio rel = TRIO_VARYING) const override; diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index dd312a80366..ef2b2cce516 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -379,69 +379,26 @@ pointer_plus_operator::op2_range (irange &r, tree type, return true; } - -class pointer_or_operator : public range_operator -{ -public: - using range_operator::op1_range; - using range_operator::op2_range; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio rel = TRIO_VARYING) const; - virtual void wi_fold (irange &r, tree type, - const wide_int &lh_lb, const wide_int &lh_ub, - const wide_int &rh_lb, const wide_int &rh_ub) const; -} op_pointer_or; - -bool -pointer_or_operator::op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2 ATTRIBUTE_UNUSED, - relation_trio) const -{ - if (lhs.undefined_p ()) - return false; - if (lhs.zero_p ()) - { - r.set_zero (type); - return true; - } - r.set_varying (type); - return true; -} - bool -pointer_or_operator::op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio) const -{ - return pointer_or_operator::op1_range (r, type, lhs, op1); -} - -void -pointer_or_operator::wi_fold (irange &r, tree type, - const wide_int &lh_lb, - const wide_int &lh_ub, - const wide_int &rh_lb, - const wide_int &rh_ub) const +operator_bitwise_or::fold_range (prange &r, tree type, + const prange &op1, + const prange &op2, + relation_trio) const { // For pointer types, we are really only interested in asserting // whether the expression evaluates to non-NULL. - if (!wi_includes_zero_p (type, lh_lb, lh_ub) - && !wi_includes_zero_p (type, rh_lb, rh_ub)) + if (!op1.zero_p () || !op2.zero_p ()) r.set_nonzero (type); - else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub)) + else if (op1.zero_p () && op2.zero_p ()) r.set_zero (type); else r.set_varying (type); + + update_known_bitmask (r, BIT_IOR_EXPR, op1, op2); + return true; } + class operator_pointer_diff : public range_operator { using range_operator::fold_range; -- 2.45.0