From patchwork Tue Feb 28 13:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 62492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3022024wrd; Tue, 28 Feb 2023 05:48:29 -0800 (PST) X-Google-Smtp-Source: AK7set9NDYKgzQ8W3zX1PBgTR7ssRWBiExI574/sT9BwHDs+4E2Y5BmQLQlNt29pQOz1lveMDM3i X-Received: by 2002:aa7:c715:0:b0:4ac:bdf7:dffd with SMTP id i21-20020aa7c715000000b004acbdf7dffdmr2957643edq.12.1677592109156; Tue, 28 Feb 2023 05:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677592109; cv=none; d=google.com; s=arc-20160816; b=QacE5lXgHxGkusJy8XSlMX51hbiYlp7G75Ew/jDziCfm0tZySptHAUd+pG3KqLzCtk IA7eh/q4tCGqQDZStVuxc7WYmUMf++6TdCP8pOt7QK+NEKrrxuGWg1Cxc3WXAcgPR7JE KMkzXVspUIScv9ojnuuXqrN/UgbaPqGh5QvsZ6XQ5ZfI3tnNSjYCxZ+8DDS8mTUEfYPA 14eAC9khUCja8aVZ+/I0yj5xebArfX0yo0Z6wJL+XMOBEUR4LM7vi/15hvLKDr8bCenL cInOSgAmCzKeyMemxQXTIqDiJKe5XcKzTt2TAwUKVW6j6FdV11ywxvenQLbia+RYonRP B1zA== 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=RUQnQXcXB0U6fIUREsdttO577V3aTfG7LxcRqCKeFoU=; b=nCk3B82Ln4Gu0Yxkr/DZpYxREwGmu6qXFJjr68E4bLB4Ux+gL+aMzPUaRqWw0d5gE4 ucpbVz6D+aOj6F8zB9dU0p00s4ZIopffXCTmhf6xp3iQ7ewfzCdYAOWGmnVUq/zbEVfY CWxf2GgztQCnyq5xQ0aCAiFUNBchBH0vgh2jA57Y/1McJyxIyZb9yaYSh4ecgn2ZfnT8 uUMEbKLHVSL1kDo+fWXwQl+IJPlZDUIfUfQDb8+DPwbPTpJ0+RgpqbwLJQMbuGud7MCd Z38OX4kjR3rVFK4RyA+D7eQQTdp5x1OJ3Pu4foua0s+aUOyRqDJ6xNv0E21xGbJ5HqSj 6z4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=R7IZVddj; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dy22-20020a05640231f600b004af6e956bd7si380246edb.421.2023.02.28.05.48.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 05:48:29 -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=R7IZVddj; 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 DDE91385087B for ; Tue, 28 Feb 2023 13:48:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDE91385087B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677592083; bh=RUQnQXcXB0U6fIUREsdttO577V3aTfG7LxcRqCKeFoU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=R7IZVddjTxz+Mg1jsaqnBgbKQ5B+wdMoy+82wjRy+8h3IvmdStpJ789DZXwyfjdV7 YFmp63iygiydDnMCpBjgpYNprte4PWwxzDIFTwHiRnOXRTJ03eg/Pe8blvi3jV5GqK oXdCTW5g26R5Cdxna8t59KNoReO/z5oNLCrp1MJg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 257A33858C39 for ; Tue, 28 Feb 2023 13:47:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 257A33858C39 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-out2.suse.de (Postfix) with ESMTPS id 56AF11FDC1 for ; Tue, 28 Feb 2023 13:47:18 +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 2C43413440 for ; Tue, 28 Feb 2023 13:47:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ImiCCeYF/mMdPwAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 13:47:18 +0000 Date: Tue, 28 Feb 2023 14:47:17 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/5] fix anti-range dumping MIME-Version: 1.0 Message-Id: <20230228134718.2C43413440@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?1759082823701893599?= X-GMAIL-MSGID: =?utf-8?q?1759082823701893599?= when vrange_printer::visit gets a VR_ANTI_RANGE it should print it as such, not just print the first element as range. When irange::num_pairs and upper/lower_bound are fixed that would no longer print a canonicalized anti-range. * value-range-pretty-print.cc (vrange_printer::visit): Handle all VR_ANTI_RANGE specially. --- gcc/value-range-pretty-print.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc index d20e2562431..23817f48a3d 100644 --- a/gcc/value-range-pretty-print.cc +++ b/gcc/value-range-pretty-print.cc @@ -64,7 +64,7 @@ vrange_printer::visit (const irange &r) const return; } // Handle legacy symbolics. - if (!r.constant_p ()) + if (!r.constant_p () || r.kind () == VR_ANTI_RANGE) { if (r.kind () == VR_ANTI_RANGE) pp_character (pp, '~'); From patchwork Tue Feb 28 13:47:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 62493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3022094wrd; Tue, 28 Feb 2023 05:48:39 -0800 (PST) X-Google-Smtp-Source: AK7set8YYQ2C0ffutCk49oSDSzQqDbG/+yJ0itSEVrTFBfP839VmLfkdvj5JwwAjronFC4PDWCVB X-Received: by 2002:a05:6402:419:b0:4af:62ad:160b with SMTP id q25-20020a056402041900b004af62ad160bmr3743775edv.5.1677592119359; Tue, 28 Feb 2023 05:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677592119; cv=none; d=google.com; s=arc-20160816; b=GOKs/y0txyaDL9BQF6+uVJkjFFSQh+MfBdJRyd2VQZDaFqLLgIPgm+6cqxmEZsmH2x pM9hP9/lRHPd9lFtiWBdjIgr08m/whb8Q/32U/iDH0qBvihlcgxZO6eSe8fCjv3iO/xe ZhoM2pnKuqI1YppS0AqBu4R2sjdn29h34e9Uw4ltzEY++4aSyOxK2wMTZsZZ37lboGfq x5FVnstlI8YooSkMONj//hfbJRkrycWuPHn/i+ONswjGauP3sERPvJmxcMBHiPPkQoGj +U4lHCkoRsyrLUKSnQBxpVrP8bEVJvsb+qqvVq3QseEZjPU54us7d+HMsTYBEIRS1jOC mSPg== 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=LpvetY519uz/HHB8RmzZ147SAWhX+nSEiGL7BFbyYoU=; b=BGh5/OIbhpswzkz02M0xzrx5/3aG7K2SMc4GwtKOxcPlFIi6SN1OFXCaIeIu8lNUBZ 3qbJaNCLRJdTJTt49bandzabcwXGMauf2IH7Stxd9FeAWGz3Do/0wLYmIeuuIiEN9oOU NT+5BUVoZaFmSqaHjilfqnvNAdfXAYvm+r7DXAqHcZDilzeHIas98J05iQe4ZGSy07Ge RpDBhg02RLzlXL+uWkdubVCRx1U7l23POsMCZMpHRjMOF+aoi+ZAferozG3qBsNMbTLq ipMHG/8QqHCjixhq+BnZVLSH5zezaQPv62M29SkG3hvsLdH/XXFyzuCvjvchkr8gD8UP rQaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="a/pQ0L5B"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l9-20020aa7c309000000b004acb4614ed5si10747365edq.117.2023.02.28.05.48.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 05:48:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="a/pQ0L5B"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 68472385021A for ; Tue, 28 Feb 2023 13:48:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68472385021A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677592090; bh=LpvetY519uz/HHB8RmzZ147SAWhX+nSEiGL7BFbyYoU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=a/pQ0L5BX61cITK6Tvt+kjZAeRfGuYgfA/ztrYHZlXnIvKO3aQpMi0KlcAolBjVIO jgd/JsyyGfM/6jvd7k6TiW6x9KRQCUO3Y0et1YKa7in37Sm32Bp/Pq0I22nnpzwga2 Z5PW5CpD8wYHcr2IFlJLdCwRXb19Tb/FaOsB3Jb0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id D255F38582B0 for ; Tue, 28 Feb 2023 13:47:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D255F38582B0 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-out2.suse.de (Postfix) with ESMTPS id 17D2E1FDC1 for ; Tue, 28 Feb 2023 13:47:25 +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 02E8813440 for ; Tue, 28 Feb 2023 13:47:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Rub5OuwF/mMnPwAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 13:47:24 +0000 Date: Tue, 28 Feb 2023 14:47:24 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/5] fend off anti-ranges from value-range-storage MIME-Version: 1.0 Message-Id: <20230228134725.02E8813440@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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?1759082834117810618?= X-GMAIL-MSGID: =?utf-8?q?1759082834117810618?= The following avoids the need to special-case storage requirement and copying for irange_storage_slot by making sure we canonicalize such ranges to int_range<2>. * tree-ssanames.cc (range_info_set_range): If receiving an anti-range recurse with a temporary int_range<2>. * value-range-storage.cc (irange_storage_slot::size): Assert we're not asking for a VR_ANTI_RANGE. --- gcc/tree-ssanames.cc | 3 +++ gcc/value-range-storage.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 08aa166ef17..23468958586 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -127,6 +127,9 @@ range_info_get_range (tree name, vrange &r) inline bool range_info_set_range (tree name, const vrange &r) { + if (r.kind () == VR_ANTI_RANGE) + return range_info_set_range (name, int_range<2> (as_a (r))); + if (!range_info_p (name) || !range_info_fits_p (name, r)) { if (range_info_p (name)) diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index bf23f6dd476..79ab2921a03 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -182,7 +182,7 @@ irange_storage_slot::get_irange (irange &r, tree type) const size_t irange_storage_slot::size (const irange &r) { - gcc_checking_assert (!r.undefined_p ()); + gcc_checking_assert (!r.undefined_p () && r.kind () != VR_ANTI_RANGE); unsigned prec = TYPE_PRECISION (r.type ()); unsigned n = num_wide_ints_needed (r); From patchwork Tue Feb 28 13:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 62496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3022624wrd; Tue, 28 Feb 2023 05:49:48 -0800 (PST) X-Google-Smtp-Source: AK7set9mpLIC13s34tzU7Q+GQxcW1AYGN/ctp8BjOGbgnvRl8pBwO0iGj+ZljhePUpEu3MoFATrH X-Received: by 2002:a05:6402:15:b0:4af:51dd:224e with SMTP id d21-20020a056402001500b004af51dd224emr3554914edu.4.1677592188033; Tue, 28 Feb 2023 05:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677592188; cv=none; d=google.com; s=arc-20160816; b=QZg3rocJliFxSrEu5GcMda5mjW/YEcb35dXQF+3gSQg6nP7/IzTZh88wDewYaisVrI dYyiosiBA4jxNvwPwPA/qt7UGjxPiPOS+EJknJPC659CXc+qUORWjCjjnFe6WEhBuwmI 6i3qfk6uA7iST2CgQc6gts2IVd68qUmg4VxwF2yu0yfVccnjIvENLQUZM0ZubCETfC4h MNCvJs5bxRnr+TQ9nv+WVwRpd41OCzrpLMakKM/rlqXgp5TGX+hNCuNURGYFrG5xGScV z6/5pjxPvgeooCuZ7xgPwlFxhEg5cUpkRdHvEe7dPzbgCQwun/JByfsEdGH1kNvHDSIV 3/ZQ== 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=EUsa4Ivl/LzW4rVRCvoVDtMKME1kX+wu8AnbAhFhmjw=; b=buHpjj/SySSIoN4BmkbblpylgDhSQUkHSNHYQlmo9xmZPqEvzeA99CAOd1u64vddjP wuwUibwgtuJApMBzqGMQcy9RYD+EKeUgtf2IxXICo2i/4SepQVjbt0dBMK6j/zIzelSW pRyKqvIihe+14Rj/jwFdJi7sDoxb68FH0AuDP1kqvpECP0vUj+JuXNtjeqgtRJZS804w JJKeZr7GlRhGfqfa0g8EQ+Kg2tX1UhVRpFHCFj3Q3tuZFFSrIcEhzqYjppeHmzZ6Nr2R ZOuhh46AiLvbCSE0B1hj+p+YByKBMMFlkPQSEat5XqtVL0Zff5bJ5eL4n105tWWXY3w9 fsFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=o46veRB9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k27-20020a17090627db00b008ddc228b077si2990511ejc.387.2023.02.28.05.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 05:49:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=o46veRB9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 5541C3858CDB for ; Tue, 28 Feb 2023 13:49:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5541C3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677592148; bh=EUsa4Ivl/LzW4rVRCvoVDtMKME1kX+wu8AnbAhFhmjw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=o46veRB9faS05nHCWGq4+r+T8IF0oKbRFzrq0sgx4ruRHMZSSLzsJ5G1uOEgHjLN5 XcsdnfUaXzwRrMJnEg3mDb7FOdJ+0IxrqXxNoiRsMT2n1RLHrN34K9IM/eGu8yFxhi 3tKdl8f+DhYUv6xHcRreFH+TQtf+MgtONaMPECrg= 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 2B6D53858D3C for ; Tue, 28 Feb 2023 13:47:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B6D53858D3C 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 638562199E for ; Tue, 28 Feb 2023 13:47:33 +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 417D113440 for ; Tue, 28 Feb 2023 13:47:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UrWuDvUF/mM7PwAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 13:47:33 +0000 Date: Tue, 28 Feb 2023 14:47:32 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/5] Avoid upper/lower_bound (1) on VR_ANTI_RANGE MIME-Version: 1.0 Message-Id: <20230228134733.417D113440@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?1759082906457832285?= X-GMAIL-MSGID: =?utf-8?q?1759082906457832285?= simplify_using_ranges::two_valued_val_range_p has odd code to verify that an anti-range is two-valued which relies on num_pairs () returning two for anti-ranges despite there's only one pair and relying on lower/upper_bound treating that argument specially. I cannot convince myself that's even correct. The following avoids this by using a temporary int_range<2> to allow anti-ranges to be represented as union of two ranges. * vr-values.cc (simplify_using_ranges::two_valued_val_range_p): Canonicalize legacy range to int_range<2> before checking for two valued-ness. --- gcc/vr-values.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 365f4976a39..c188fff1f8c 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -2189,11 +2189,12 @@ bool simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b, gimple *s) { - value_range vr = *query->get_value_range (var, s); - vr.normalize_symbolics (); - if (vr.varying_p () || vr.undefined_p ()) + value_range r = *query->get_value_range (var, s); + r.normalize_symbolics (); + if (r.varying_p () || r.undefined_p ()) return false; + int_range<2> vr (r); if ((vr.num_pairs () == 1 && vr.upper_bound () - vr.lower_bound () == 1) || (vr.num_pairs () == 2 && vr.lower_bound (0) == vr.upper_bound (0) From patchwork Tue Feb 28 13:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 62497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3022855wrd; Tue, 28 Feb 2023 05:50:20 -0800 (PST) X-Google-Smtp-Source: AK7set9/QWouzveNax3yy//RKhBwbUFCRnRoU9MJFXPKEAjir2GeYhDdlZN7tZIh+4/yae7jXqq/ X-Received: by 2002:aa7:d6c7:0:b0:4ad:828b:970 with SMTP id x7-20020aa7d6c7000000b004ad828b0970mr2928843edr.33.1677592220393; Tue, 28 Feb 2023 05:50:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677592220; cv=none; d=google.com; s=arc-20160816; b=NcPSbLfwOUoTr9f/cwXmoidWO4ctNvFh7FBnStmPh/KuiWm401nQSZGcUOC+NZxtcY OQa0KoxjxG8EsxOzrqTL7T1RkwJ4i7fgmQXCchcNTDmGd5WkL8kcwRG7VKa8FRITQ4ZU e2ObKRWnLVhPSGgy3bV5lMIHObwBfZNWjKdS/KST4x1tNxvkregDJpfZ9+D9VHvXLVwV hP9Z5lQwJDw9JWmacbW/eVSOdLCCjwQAZIHBs/aRWdwIFb4IaCv8/fwQMKimVsH6FueQ DA9a0OFRjQQQH8DQ/FCLqopejRPd0x+hY6McdXlrPhNDcJujjQe8gFNtkwDfkRE3O6qN d6mw== 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=OPzqqUHmmrGHH4AtPPZMFnOLUJoz1Mu/hXKtSOp07N0=; b=sxA/AYcJm5U+0GIngUUEWQ6K/RZ3BsC3PUL2vXOjrUcpbjGmhtYYpiva9BDkW63Aky 2Bo0vHTRZ+FIvfFTXnVtd979vDu/Pa0PfyrrkYKPWojH0GZ/hxtZd1q5sDD0S1FDc/sa OCRoCF4r/Eid3GWRfdWLYXfj+2JOj8RtepW3I+o7waaCxwUKxUQ5keAI6a/nXQYYfWHX 97KRD1RsfYaK+4+1H8i+qhQLhCoIbn/ICMKNic/Eu69vHJRi9qSkTODcb9lNRgfqmzss 8owQHberswg6D56iOitQgalV5c8DL58L08AZXLlpYB5oe+wOS8ijG53lCJHhsUHB3a2J GxNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DXzq7KNF; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i20-20020aa7dd14000000b004ad0c7d39b0si11379099edv.297.2023.02.28.05.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 05:50:20 -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=DXzq7KNF; 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 D3B67385841C for ; Tue, 28 Feb 2023 13:50:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3B67385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677592205; bh=OPzqqUHmmrGHH4AtPPZMFnOLUJoz1Mu/hXKtSOp07N0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DXzq7KNF1qQYuzTQZQebgvuUKdD7clymYA528krae4ZQr5pxPn3gS8i9R9P/pxk9D Ngbvys3w4hdOkGb0GM2fwmpL68/0cc/+foiDvE+ge9LWVIBAgb2L6j1zyNBwTwnucG E6PTBuBhRsatvRrTSHtAH9dbAwyhwXzsHXro0hmA= 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 BEB12385781A for ; Tue, 28 Feb 2023 13:47:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEB12385781A 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 024812199E for ; Tue, 28 Feb 2023 13:47:40 +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 E030413440 for ; Tue, 28 Feb 2023 13:47:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rs82NfsF/mNuPwAAMHmgww (envelope-from ) for ; Tue, 28 Feb 2023 13:47:39 +0000 Date: Tue, 28 Feb 2023 14:47:39 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/5] Sanitize irange::num_pairs MIME-Version: 1.0 Message-Id: <20230228134739.E030413440@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?1759082940339078670?= X-GMAIL-MSGID: =?utf-8?q?1759082940339078670?= irange::num_pairs has odd behavior for VR_ANTI_RANGE where it claims there are two pairs when there's actually only one. The following is now able to get rid of this, also fixing irange::legacy_upper_bound which special-cased ~[-INF, up] to return +INF instead of properly doing that when up is not +INF. * value-range.h (irange::num_pairs): Always return m_num_ranges. * value-range.cc (irange::legacy_lower_bound): Remove pair == 1 case. (irange::legacy_upper_bound): Likewise. Properly special-case ~[low, +INF]. --- gcc/value-range.cc | 6 ++++-- gcc/value-range.h | 5 +---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index a535337c47a..143af5601c7 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1208,7 +1208,8 @@ irange::legacy_lower_bound (unsigned pair) const if (m_kind == VR_ANTI_RANGE) { tree typ = type (), t; - if (pair == 1 || vrp_val_is_min (min ())) + 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); @@ -1235,7 +1236,8 @@ irange::legacy_upper_bound (unsigned pair) const if (m_kind == VR_ANTI_RANGE) { tree typ = type (), t; - if (pair == 1 || vrp_val_is_min (min ())) + 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); diff --git a/gcc/value-range.h b/gcc/value-range.h index f4ac73b499f..cfb51bad915 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -614,10 +614,7 @@ vrange::kind () const inline unsigned irange::num_pairs () const { - if (m_kind == VR_ANTI_RANGE) - return constant_p () ? 2 : 1; - else - return m_num_ranges; + return m_num_ranges; } inline tree 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)); }