From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65486 invoked by alias); 4 Oct 2019 16:29:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65476 invoked by uid 89); 4 Oct 2019 16:29:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*RU:209.85.128.68, HX-Spam-Relays-External:209.85.128.68 X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 16:29:08 +0000 Received: by mail-wm1-f68.google.com with SMTP id r19so6491408wmh.2 for ; Fri, 04 Oct 2019 09:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=9hwmbcbNh3VMRvILx/v2jb7gi26UY9fFhfuT1mRoiQU=; b=kXhSAzY6oCeoaCoHdKAhpWmt6CV19VXjMNCaPUhV8YrDZoGEVTkz4ciR3quBw7Xa2w HeHA4CmaKtaufwuQVTDybs8OHN0LykcnqAIvOclhXXqRWrHfVByebGZUcII2eRELLg4t JYCdIO8xk2+KNtSwDcB0eZ9lVSRa7OtT3HvRKAq3v7xMEI/eP2wUyJ7WRGE2ZzPFBD6x UhebHNzr5JiklktVwZHxGRNHEcySzJtZSRdNKz39oEi0OCk0PuqChWZJRXvdWmHUBkjh q2Yv3RuCu929TtpAUjjd/sR2sPNcg8lVq3FMsbC/jInQyxtIL1G3Wcc27Xr84yHj/uIb dXtA== Return-Path: Received: from [192.168.178.32] (x4d07449b.dyn.telefonica.de. [77.7.68.155]) by smtp.gmail.com with ESMTPSA id w7sm6843390wmd.22.2019.10.04.09.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Oct 2019 09:29:05 -0700 (PDT) Date: Fri, 04 Oct 2019 16:29:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <995b4560-6a76-6742-888f-eadbfb9ff9cc@redhat.com> References: <995b4560-6a76-6742-888f-eadbfb9ff9cc@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [patch] canonicalize unsigned [1,MAX] ranges into ~[0,0] To: gcc-patches@gcc.gnu.org,Jeff Law ,Aldy Hernandez CC: gcc-patches ,Andrew MacLeod From: Richard Biener Message-ID: X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00353.txt.bz2 On October 4, 2019 5:38:09 PM GMT+02:00, Jeff Law wrote: >On 10/4/19 6:59 AM, Aldy Hernandez wrote: >> When I did the value_range canonicalization work, I noticed that an >> unsigned [1,MAX] and an ~[0,0] could be two different representations >> for the same thing.=C2=A0 I didn't address the problem then because >callers >> to ranges_from_anti_range() would go into an infinite loop trying to >> extract ~[0,0] into [1,MAX] and [].=C2=A0 We had a lot of callers to >> >ranges_from_anti_range,=C2=A0and=C2=A0it=C2=A0smelled=C2=A0like=C2=A0a=C2= =A0rat's=C2=A0nest,=C2=A0so=C2=A0I=C2=A0bailed. >>=20 >> Now that we have one main caller (from the symbolic PLUS/MINUS >> handling), it's a lot easier to contain.=C2=A0 Well, singleton_p also >calls >> >it,=C2=A0but=C2=A0it's=C2=A0already=C2=A0handling=C2=A0nonzero=C2=A0specia= lly,=C2=A0so=C2=A0it=C2=A0wouldn't=C2=A0be=C2=A0affected. >>=20 >>=20 >> With some upcoming cleanups I'm about to post, the fact that [1,MAX] >and >> ~[0,0] are equal_p(), but not nonzero_p(), matters.=C2=A0 Plus, it's just >> good form to have one representation, giving us the ability to pick >at >> nonzero_p=C2=A0ranges=C2=A0with=C2=A0ease. >>=20 >> The code in extract_range_from_plus_minus_expr() continues to be a >mess >> (as it has always been), but at least it's contained, and with this >> patch,=C2=A0it's=C2=A0slightly=C2=A0smaller. >>=20 >> Note, I'm avoiding adding a comment header for functions with highly >> descriptive=C2=A0obvious=C2=A0names. >>=20 >> OK? >>=20 >> Aldy >>=20 >> canonicalize-nonzero-ranges.patch >>=20 >> commit 1c333730deeb4ddadc46ad6d12d5344f92c0352c >> Author: Aldy Hernandez >> Date: Fri Oct 4 08:51:25 2019 +0200 >>=20 >> Canonicalize UNSIGNED [1,MAX] into ~[0,0]. >>=20=20=20=20=20 >> Adapt PLUS/MINUS symbolic handling, so it doesn't call >> ranges_from_anti_range with a VR_ANTI_RANGE containing one >sub-range. >>=20 >> diff --git a/gcc/ChangeLog b/gcc/ChangeLog >> index 6e4f145af46..3934b41fdf9 100644 >> --- a/gcc/ChangeLog >> +++ b/gcc/ChangeLog >> @@ -1,3 +1,18 @@ >> +2019-10-04 Aldy Hernandez >> + >> + * tree-vrp.c (value_range_base::singleton_p): Use num_pairs >> + instead of calling vrp_val_is_*. >> + (value_range_base::set): Canonicalize unsigned [1,MAX] into >> + non-zero. >> + (range_has_numeric_bounds_p): New. >> + (range_int_cst_p): Use range_has_numeric_bounds_p. >> + (ranges_from_anti_range): Assert that we won't recurse >> + indefinitely. >> + (extract_extremes_from_range): New. >> + (extract_range_from_plus_minus_expr): Adapt so we don't call >> + ranges_from_anti_range with an anti-range containing only one >> + sub-range. >So no problem with the implementation, but I do have a higher level >question. > >One of the goals of the representation side of the Ranger project is to >drop anti-ranges. Canonicalizing [1, MAX] to ~[0,0] seems to be going >in the opposite direction. So do we really want to canonicalize to >~[0,0]? No, we don't.=20 Richard.=20 >jeff