From patchwork Tue Feb 28 13:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 62495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3022480wrd; Tue, 28 Feb 2023 05:49:32 -0800 (PST) X-Google-Smtp-Source: AK7set9MQhh2Zitf68RnOeL2oeJ6V3cE938QlWRyS+mZTvB+Wta0x2tS5SYO5sswnINAYo6ohbsQ X-Received: by 2002:a17:906:b08e:b0:8b1:7ae9:647 with SMTP id x14-20020a170906b08e00b008b17ae90647mr2161668ejy.76.1677592172087; Tue, 28 Feb 2023 05:49:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677592172; cv=none; d=google.com; s=arc-20160816; b=i26qr1WM87AExh4QDWxGAi9WQuj/zh4mlmiADAB+fcRTCMndLEcBQNZmNx6yPO+fj6 mObTowZ0lQ0BashbyypmKofrsyf/A/jZXpAHOsUgenkIV59KvElYbs6tQguFdnpq8DHf Vtx3gmuSUktU0XKsRfvbP2CV6fauejx5ojW70C7m6cMT7V8eUPMh6YJ9z73mDLTPGDJw +ZeBxHZ5pu9m0vzOhTmrOCvqylEODq0Hfp1DPdAnlXkfUfgz3mm7nuJEVarIBhcVC01v WW+/MNvIBuS2Ejg0WN7Rp4q2kMoN8bFYu6UZTTIr4VuRBArig2HZVO13MQLxMF6nFBlp 9VcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=6on1eYmNCjX+Ie7x9fdAXe6qzzZk1NGWEax1wrav764=; b=Q7IFE4azsLytqwTztZjNBsXP1s8ueR5csgedUKA83iBeBNu8NolkRet4XQbz8x/ajF FFRoPwSwO8SZTN5MlTRGDh/ZET6amna0aXEN3JiIldsf8faVqOFCmNflBD1XxA8O3WpT mCT5DZml5g1CeGPaB94iAKW2r6bcpi6MMV8wBzUNdWikETxYuuqOaOBpOowhJQOIrI/L oHXhqxu6FEs5eUe/FcQbsB0/H+CZkg2UkT8IEAymZDVm7QvN0PebH94TqvRMurSus7es 5vMl2X6MIPjyJUFfSVV1F3jA8I5MR9Jsh82FSgZAuTaAmnrCU7dpSlHKLWwQqh+1+roI 7JTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vrr8j8bc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g26-20020a170906595a00b008cf5d3457acsi436632ejr.810.2023.02.28.05.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 05:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vrr8j8bc; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B54B385086E for ; Tue, 28 Feb 2023 13:48:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B54B385086E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677592134; bh=6on1eYmNCjX+Ie7x9fdAXe6qzzZk1NGWEax1wrav764=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vrr8j8bc6yIFK1M7m0qZfcg0ab0csO+f5BdUcsutnxzCv/kIIqisJwm+Ms4/Q34Ty MgeztrvSXhryZK64WlP753ChJyqQ4YX0Z0QsMZa/yLr5UM17Ou014JWdmSR0/SYL5o qol907m1TPepll6ltARls+E4H+kfQ8RYFQMQPkng= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id D8E9A385558F for ; Tue, 28 Feb 2023 13:47:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8E9A385558F Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C78721A52 for ; Tue, 28 Feb 2023 13:47:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 07F8D13440 for ; Tue, 28 Feb 2023 13:47:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2HHUAAQG/mObPwAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 13:47:48 +0000 Date: Tue, 28 Feb 2023 14:47:47 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/5] Sanitize legacy_{lower,upper}_bound MIME-Version: 1.0 Message-Id: <20230228134748.07F8D13440@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759082889862293735?= X-GMAIL-MSGID: =?utf-8?q?1759082889862293735?= * value-range.h (irange::legacy_lower_bound): Remove pair argument. (irange::legacy_upper_bound): Likewise. (irange::lower_bound): Commonize asserts, adjust. (irange::upper_bound): Likewise. * value-range.cc (irange::legacy_lower_bound): Remove asserts done in the caller. Use min/max consistently. (irange::legacy_upper_bound): Likewise. --- gcc/value-range.cc | 24 ++++++++---------------- gcc/value-range.h | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 143af5601c7..eaf6139a1b5 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1190,60 +1190,52 @@ irange::verify_range () } } -// Return the lower bound for a sub-range. PAIR is the sub-range in -// question. +// Return the lower bound for a sub-range. wide_int -irange::legacy_lower_bound (unsigned pair) const +irange::legacy_lower_bound () const { gcc_checking_assert (legacy_mode_p ()); if (symbolic_p ()) { value_range numeric_range (*this); numeric_range.normalize_symbolics (); - return numeric_range.legacy_lower_bound (pair); + return numeric_range.legacy_lower_bound (); } - gcc_checking_assert (m_num_ranges > 0); - gcc_checking_assert (pair + 1 <= num_pairs ()); if (m_kind == VR_ANTI_RANGE) { tree typ = type (), t; - gcc_checking_assert (pair == 0); if (vrp_val_is_min (min ())) t = wide_int_to_tree (typ, wi::to_wide (max ()) + 1); else t = vrp_val_min (typ); return wi::to_wide (t); } - return wi::to_wide (tree_lower_bound (pair)); + return wi::to_wide (min ()); } -// Return the upper bound for a sub-range. PAIR is the sub-range in -// question. +// Return the upper bound for a sub-range. wide_int -irange::legacy_upper_bound (unsigned pair) const +irange::legacy_upper_bound () const { gcc_checking_assert (legacy_mode_p ()); if (symbolic_p ()) { value_range numeric_range (*this); numeric_range.normalize_symbolics (); - return numeric_range.legacy_upper_bound (pair); + return numeric_range.legacy_upper_bound (); } - gcc_checking_assert (m_num_ranges > 0); - gcc_checking_assert (pair + 1 <= num_pairs ()); if (m_kind == VR_ANTI_RANGE) { tree typ = type (), t; - gcc_checking_assert (pair == 0); if (!vrp_val_is_max (max ())) t = vrp_val_max (typ); else t = wide_int_to_tree (typ, wi::to_wide (min ()) - 1); return wi::to_wide (t); } - return wi::to_wide (tree_upper_bound (pair)); + return wi::to_wide (max ()); } bool diff --git a/gcc/value-range.h b/gcc/value-range.h index cfb51bad915..ed8163ed218 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -193,8 +193,8 @@ protected: void legacy_union (irange *, const irange *); void legacy_intersect (irange *, const irange *); void verify_range (); - wide_int legacy_lower_bound (unsigned = 0) const; - wide_int legacy_upper_bound (unsigned) const; + wide_int legacy_lower_bound () const; + wide_int legacy_upper_bound () const; int value_inside_range (tree) const; bool maybe_anti_range () const; void copy_to_legacy (const irange &); @@ -918,10 +918,13 @@ irange::set_varying (tree type) inline wide_int irange::lower_bound (unsigned pair) const { - if (legacy_mode_p ()) - return legacy_lower_bound (pair); gcc_checking_assert (m_num_ranges > 0); gcc_checking_assert (pair + 1 <= num_pairs ()); + if (legacy_mode_p ()) + { + gcc_checking_assert (pair == 0); + return legacy_lower_bound (); + } return wi::to_wide (tree_lower_bound (pair)); } @@ -931,10 +934,13 @@ irange::lower_bound (unsigned pair) const inline wide_int irange::upper_bound (unsigned pair) const { - if (legacy_mode_p ()) - return legacy_upper_bound (pair); gcc_checking_assert (m_num_ranges > 0); gcc_checking_assert (pair + 1 <= num_pairs ()); + if (legacy_mode_p ()) + { + gcc_checking_assert (pair == 0); + return legacy_upper_bound (); + } return wi::to_wide (tree_upper_bound (pair)); }