From patchwork Thu Oct 24 12:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 2001707 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=BrXVwL25; 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 4XZ5T65Qzqz1xtp for ; Thu, 24 Oct 2024 23:53:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCFBE3858405 for ; Thu, 24 Oct 2024 12:53:57 +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 1E5DB3858C98 for ; Thu, 24 Oct 2024 12:53:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E5DB3858C98 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 1E5DB3858C98 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=1729774409; cv=none; b=XTBenRn3DVZ/duvd73b6A299hBlih22BZLEqozNAlUIKj+2Ccb7VzenijB74vBIl2scAGcVIaSBvz70sUMKzodWMlaTMSkmZUPrdRA2pahpVgNB/1zoxeNUI1iY6qEwlYD999yffxFYPE8c1yk1vIuCC6LzVTfNjacBLh5WYuhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729774409; c=relaxed/simple; bh=Oc+USvmpbolsWk7KRnNOjG7WakoHcR0UyJbR+rqQFxk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=WPp0+H6XxwguSr0DJa0/szYDyb74gFxZjP2BZnGspzRRKUMXQGfGoii02OGA+Epwopoait2kAztdVjyxWOmw134+EW8dZqkXY53wP0g7DP78vFBfDrFE11Qi5CB4p2SPKQJMZn80d73xIbqnahDlV1U+wZwvTo/g+uQzrYdyjS0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729774405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=ouKeK6zvcf7y9yVrJa5So6/UzG/xiBC6ukavn/YkhWs=; b=BrXVwL253KtNTtI2u+lVyMpbLQ+mn1rvCEaAvA8u+N3v53rClqbJcGw1SnzdS1w/aIpyJW pv0wj4v1GREfv80bTWpR8XV42U/riMVBks5HHL5lmqTH9S58bpUBf1d6ZqjKluTs+59H+y 7V5+CdUHdnKjOxKOUiV1pkkZBF8uApc= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-IzoWObmdPLCV6Ij94uoC7g-1; Thu, 24 Oct 2024 08:53:24 -0400 X-MC-Unique: IzoWObmdPLCV6Ij94uoC7g-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cbe4fc0aa7so11586116d6.0 for ; Thu, 24 Oct 2024 05:53:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729774403; x=1730379203; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ss/yH7FYtjCzasNGELWyyH+tsenOBHOIGsY38oN022I=; b=SEjVj1lmX0xmExvQ+yzht6npg4KlNBeKLMKsHHv61fmL7zi3z6bWJ5ZUe6qLS1Sy8+ 70WRuWMksy1YRHFqakgRdYQ6oYZERIAsBklMmkcwy8gKNSIxm1tXwai3Q/4Wt9gY7Em0 ZcKjr8v6zHg3matoxNgh80AVjbv0/VFNz5xSXDzCW4oR5LzvsU5mfikqEnPia8bOkvcO zCe4aA81u3MwRepZdEHZt/ZTyC7Q5q/84d+09Dw/lx1iA8p5nuD04PWfOJdRzBfL4+qn mF1TJ3YISV49kDC8GaLLBwl6+5ay2bhcs2h2AHqwqAvqHBO3zdidwkxZRat+BZESVY4z xlXw== X-Gm-Message-State: AOJu0Yx+srhsDK24KcGMdA7uMGzF97nigzONz74MZqVgbP67yD/wTkTz MFVttQN/Pr1wY2a904dXKJdN/H66Od51DMUjeBDWQnv6RYcZ2s+JTfUplQR9BJjgA6GcGlc+AX7 /tPPfVUfqqlrebqRVdYG2FbbJTof6k1i161XebWEdtxuWanUMqE88rdFKoiOmrYLn+D7DKocgZX VHZwpElZpE3SFsH3ID6c9ixBRyz5DcVYp0F9wiohS3yA== X-Received: by 2002:a05:6214:4489:b0:6cb:4b70:8ead with SMTP id 6a1803df08f44-6ce342864famr78297436d6.37.1729774403571; Thu, 24 Oct 2024 05:53:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH0FtrovzVvNTFi6l0d99Egfx+pFKlgQVORsUbpYP6V56/c+KFZuuJ1600jZHgfS7I/C1hNw== X-Received: by 2002:a05:6214:4489:b0:6cb:4b70:8ead with SMTP id 6a1803df08f44-6ce342864famr78297186d6.37.1729774403111; Thu, 24 Oct 2024 05:53:23 -0700 (PDT) Received: from [192.168.0.174] ([104.219.121.80]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ce00999a91sm49292466d6.88.2024.10.24.05.53.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Oct 2024 05:53:21 -0700 (PDT) Message-ID: Date: Thu, 24 Oct 2024 08:53:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches , aldy@quesejoda.com From: Andrew MacLeod Subject: [COMMITTED 1/4] - Cleanup pointer_plus_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 when looking at 117222, I discovered the prange operators need a bit of auditing. pointer_plus should be functioning properly, but there were some pre-Prange remnants hanging around.. there were wide_int and irange based routines which can no longer be called, so they are dead code and this removed them. Bootstraps on x86_64-pc-linux-gnu with no regressions.  pushed. Andrew From 4eb25bfee859a9161c0fd48215feaf1c307f2480 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 21 Oct 2024 16:47:32 -0400 Subject: [PATCH 1/4] Cleanup pointer_plus_operator. The POINTER_PLUS operator still carries some remnamts of the old irange interface, which is now dead code with prange. * range-op-ptr.cc (pointer_plus_operator::wi_fold): Remove. (pointer_plus_operator::op2_range): Remove irange variant. (pointer_plus_operator::update_bitmask): Likewise. --- gcc/range-op-ptr.cc | 74 +-------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 07a551618f9..4f4b2cf6bab 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -302,16 +302,7 @@ public: const prange &lhs, const prange &op1, relation_trio = TRIO_VARYING) const final override; - 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; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const + void update_bitmask (prange &r, const prange &lh, const irange &rh) const { update_known_bitmask (r, POINTER_PLUS_EXPR, lh, rh); } } op_pointer_plus; @@ -388,69 +379,6 @@ pointer_plus_operator::op2_range (irange &r, tree type, return true; } -void -pointer_plus_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 -{ - // Check for [0,0] + const, and simply return the const. - if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub) - { - r.set (type, rh_lb, rh_lb); - return; - } - - // For pointer types, we are really only interested in asserting - // whether the expression evaluates to non-NULL. - // - // With -fno-delete-null-pointer-checks we need to be more - // conservative. As some object might reside at address 0, - // then some offset could be added to it and the same offset - // subtracted again and the result would be NULL. - // E.g. - // static int a[12]; where &a[0] is NULL and - // ptr = &a[6]; - // ptr -= 6; - // ptr will be NULL here, even when there is POINTER_PLUS_EXPR - // where the first range doesn't include zero and the second one - // doesn't either. As the second operand is sizetype (unsigned), - // consider all ranges where the MSB could be set as possible - // subtractions where the result might be NULL. - if ((!wi_includes_zero_p (type, lh_lb, lh_ub) - || !wi_includes_zero_p (type, rh_lb, rh_ub)) - && !TYPE_OVERFLOW_WRAPS (type) - && (flag_delete_null_pointer_checks - || !wi::sign_mask (rh_ub))) - r.set_nonzero (type); - else if (lh_lb == lh_ub && lh_lb == 0 - && rh_lb == rh_ub && rh_lb == 0) - r.set_zero (type); - else - r.set_varying (type); -} - -bool -pointer_plus_operator::op2_range (irange &r, tree type, - const irange &lhs ATTRIBUTE_UNUSED, - const irange &op1 ATTRIBUTE_UNUSED, - relation_trio trio) const -{ - relation_kind rel = trio.lhs_op1 (); - r.set_varying (type); - - // If the LHS and OP1 are equal, the op2 must be zero. - if (rel == VREL_EQ) - r.set_zero (type); - // If the LHS and OP1 are not equal, the offset must be non-zero. - else if (rel == VREL_NE) - r.set_nonzero (type); - else - return false; - return true; -} - class pointer_min_max_operator : public range_operator { public: -- 2.45.0