From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id A1A393858D32 for ; Tue, 5 Sep 2023 07:12:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1A393858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-56a55c0f8b1so1000702a12.0 for ; Tue, 05 Sep 2023 00:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693897942; x=1694502742; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2tkS9y1xNTu3rt8VdxRaQICVZNAJAyWpAfxQzfvvUY0=; b=abeyXGfI38eiHp/MRvCU8Jq9OPLW8DcXBzCEhVbMZV0ol+NJZyh3CzKqh4IaNCSBjc mg/fScHGZp+EzLRamPdE45sKarGw47mEBnGx/oeW0XemODDaFQrFWYz7ckUG9ptPe4RB 4EvR83hTvgZMgWpiY6a3vg/UdajKkEd0NBLhZsfydxbUKTJ3vuSZyfBgorZXrRBxNyP2 BElQBNNZtCGPRVxFYDu9wn/7nbE1GACwrCcHC+jOJc4sxChq6MdfFMiGsIyOaa4dfuV+ hDl1ERZ020/AwMAxZpjH6ZqeAtinrrFPzPYyyGPoLqtoXN1lVgSY7oLYBnIJM47MzdqO Hb9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693897942; x=1694502742; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2tkS9y1xNTu3rt8VdxRaQICVZNAJAyWpAfxQzfvvUY0=; b=TkSDI+0zhvoUs6OR3lfWXh/ZKneIMjfpH8EkCaImKnFo4cz7BAUHEeJ82HQegD3SJL rxI20/gLn0lTtRJTO1by3Weov92L5OZDtIaQ+AYvRKeC0k75LFkgd9XZsILMKDQNb8XJ OmQQT7bEF5S8XozcON1vC+FrM++n5MhlgtdlMxX/BbU/69k5CZlmWzAr444oJUsNgMPS HTI5/o3yYHOZVptiONuxIs50hfYVOPoZGrIhfx4hf7A9p3sJthXwfSDcGITDBRkDMuBP 0YcjqB8NsBAZ9YVPku7b5cy62rTi0xznsFHiOBN6qtrgXJcKGvs5y/1/yYAqW87JPz73 xyRw== X-Gm-Message-State: AOJu0YyxfganBIp+bevM/VU2Kzn/agnnu7MNgRCisDvIHZYajdMqkSIk sgaOaJx52c4WR1PQuFac/zb9/Y7iugabYqIEeq8= X-Google-Smtp-Source: AGHT+IGca/6rhC4DiPjwIQXrWDgmR4F4qAf4Nfv8BHN3EF9p0GSTXwevP9qBCWhFbwBveZ9+4VexmU2LVmudwx/8qBg= X-Received: by 2002:a05:6a21:718b:b0:137:514a:984f with SMTP id wq11-20020a056a21718b00b00137514a984fmr9530232pzb.35.1693897942397; Tue, 05 Sep 2023 00:12:22 -0700 (PDT) MIME-Version: 1.0 References: <20230901173059.791894-1-apinski@marvell.com> <20230901173059.791894-2-apinski@marvell.com> <23a3e21c-eae5-44d0-8e66-65ada10a9c4d@gmail.com> In-Reply-To: <23a3e21c-eae5-44d0-8e66-65ada10a9c4d@gmail.com> From: Andrew Pinski Date: Tue, 5 Sep 2023 00:12:10 -0700 Message-ID: Subject: Re: [PATCH 2/2] VR-VALUES: Rewrite test_for_singularity using range_op_handler To: Jeff Law Cc: Andrew Pinski , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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 List-Id: On Mon, Sep 4, 2023 at 11:06=E2=80=AFPM Jeff Law via Gcc-patches wrote: > > > > On 9/1/23 11:30, Andrew Pinski via Gcc-patches wrote: > > So it turns out there was a simplier way of starting to > > improve VRP to start to fix PR 110131, PR 108360, and PR 108397. > > That was rewrite test_for_singularity to use range_op_handler > > and Value_Range. > > > > This patch implements that and > > > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > > > gcc/ChangeLog: > > > > * vr-values.cc (test_for_singularity): Add edge argument > > and rewrite using range_op_handler. > > (simplify_compare_using_range_pairs): Use Value_Range > > instead of value_range and update test_for_singularity call. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/tree-ssa/vrp124.c: New test. > > * gcc.dg/tree-ssa/vrp125.c: New test. > > --- > > > diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc > > index 52ab4fe6109..2474e57ee90 100644 > > --- a/gcc/vr-values.cc > > +++ b/gcc/vr-values.cc > > @@ -904,69 +904,33 @@ simplify_using_ranges::simplify_bit_ops_using_ran= ges > > } > > > > /* We are comparing trees OP1 and OP2 using COND_CODE. OP1 has > > - a known value range VR. > > + a known value range OP1_RANGE. > > > > If there is one and only one value which will satisfy the > > - conditional, then return that value. Else return NULL. > > - > > - If signed overflow must be undefined for the value to satisfy > > - the conditional, then set *STRICT_OVERFLOW_P to true. */ > > + conditional on the EDGE, then return that value. > > + Else return NULL. */ > > > > static tree > > test_for_singularity (enum tree_code cond_code, tree op1, > > - tree op2, const value_range *vr) > > + tree op2, const int_range_max &op1_range, bool edge= ) > > { > > - tree min =3D NULL; > > - tree max =3D NULL; > > - > > - /* Extract minimum/maximum values which satisfy the conditional as i= t was > > - written. */ > > - if (cond_code =3D=3D LE_EXPR || cond_code =3D=3D LT_EXPR) > > + /* This is already a singularity. */ > > + if (cond_code =3D=3D NE_EXPR || cond_code =3D=3D EQ_EXPR) > > + return NULL; > I don't think this is necessarily the right thing to do for NE. > > Consider if op1 has the range [0,1] and op2 has the value 1. If the > code is NE, then we should be able to return a singularity of 0 since > that's the only value for x where x ne 1 is true given the range for x. The "false" edge singularity is already known when NE is supplied. I don't think changing it to the "true" edge singularity will be helpful all of the time; preferring the value of 0 is a different story. But that is a different patch and for a different location rather than inside VRP; it should be in either isel or expand (more likely isel). Thanks, Andrew > > > > I like what you're trying to do, it just needs a bit of refinement I thin= k. > > jeff