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)