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