From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 9E6E33858C01 for ; Mon, 18 Sep 2023 09:04:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E6E33858C01 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-lf1-x12c.google.com with SMTP id 2adb3069b0e04-503012f4e71so2007714e87.0 for ; Mon, 18 Sep 2023 02:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695027869; x=1695632669; 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=RHAQ3a4WGc1SjdmrObAojf4aROSfpjzHX1JihSPDDQQ=; b=FNYs9DAeJ2saImsC4YDRtfXCNg5Qujd7A/L4otg3MQ02Hp6fzBvm6CRMPov9BRXZGb EWLayORXizXpOGwV3plraGbkLgeGrx/qh1PA7vqvuJR6rkE+5JdZ9owkq8g6VI0NwhaR J9LxQ7yhY1HHhOxE4Uiw/Rd/fg6uiSunijkQKjloFui9RvqPiB7zNmGc8r8aMOMVozs1 s/JA/a9Gr9VBfu6WRQPBpHImsxFXy94wXp3LuqeNAutyaUNvAHD8Jvs1wKuSBMAnhvVE wbCTPxrTEW5AwteENNJugDdgw69H/VYNmTnYlVMBaOJ0qTkDKu9LXm7G71XahUjn5A/7 Z2TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695027869; x=1695632669; 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=RHAQ3a4WGc1SjdmrObAojf4aROSfpjzHX1JihSPDDQQ=; b=TZ6vriw4lvmw7yhJOlRuOmn580zEr6+Tw72UQBqPIL5Z+46OFCv1TtSsa0TAxPyclO dAg0XBsIy5jUxuWcj8Uc52xbvo7WT0EuCIPK05Mt97aKijuCVlKAXT9ie/kyi70woH54 Qa0GFT8dFHjVUU2yDIDX+c5qDuTU9Y7ga4CEgX3ey3wEmbMfWo/3VWPMiGHvA8/NSi8x aIDsE53Dzm9KInBmqy2NwdBZ8H8PI9jvsENEwMIF2JTPtYPFDg9lbP3I8kSupu6Q56hp X26hcRrWnf+1hurDx16iybUpVl0i1iwJZGZBHEnpc3gU6kzFkxXL+Xa9qhH8AcXsHk4Q tACA== X-Gm-Message-State: AOJu0Yx9ktMbsHi1WNHyrl0M1TVtWGOIw6LgUTSSx4tIbJovzgbUr0y+ ViMr1ZtWGPhEDiZoJ6S+FTJ+qLyVcoqqa7GQx5j/qknI X-Google-Smtp-Source: AGHT+IF2ej6bSGFx0ItBgtxD7h0lr/GckiWQTWHj8vEmYRQfjdOZm7RouqwOFoo1rtGDwWWnVPY1kLAe9+f/q7TZKg4= X-Received: by 2002:a05:6512:3fc:b0:4fb:7624:85a5 with SMTP id n28-20020a05651203fc00b004fb762485a5mr2426271lfq.0.1695027868680; Mon, 18 Sep 2023 02:04:28 -0700 (PDT) MIME-Version: 1.0 References: <20230917214055.1752964-1-apinski@marvell.com> In-Reply-To: <20230917214055.1752964-1-apinski@marvell.com> From: Richard Biener Date: Mon, 18 Sep 2023 11:04:16 +0200 Message-ID: Subject: Re: [PATCH] MATCH: Make zero_one_valued_p non-recusive fully To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.4 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 Sun, Sep 17, 2023 at 11:41=E2=80=AFPM Andrew Pinski via Gcc-patches wrote: > > So it turns out VN can't handle any kind of recusion for match. In this > case we have `b =3D a & -1` and we try to match a as being zero_one_value= d_p > and VN returns b as being the value and we just go into an infinite loop = at > this point. Huh, interesting. Must be because we return an available expression for the b, a & -1 equivalency class. Otherwise I'd have expected you get 'a'. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. Richard. > Note genmatch should warn (or error out) if this gets detected so I filed= PR 111446 > which I will be looking into next week or the week after so we don't run = into > this issue again. > > PR tree-optimization/111442 > > gcc/ChangeLog: > > * match.pd (zero_one_valued_p): Have the bit_and match not be > recusive. > > gcc/testsuite/ChangeLog: > > * gcc.c-torture/compile/pr111442-1.c: New test. > --- > gcc/match.pd | 5 ++++- > gcc/testsuite/gcc.c-torture/compile/pr111442-1.c | 13 +++++++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr111442-1.c > > diff --git a/gcc/match.pd b/gcc/match.pd > index 887665633d4..773c3810f51 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -2183,8 +2183,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > /* (a&1) is always [0,1] too. This is useful again when > the range is not known. */ > +/* Note this can't be recusive due to VN handling of equivalents, > + VN and would cause an infinite recusion. */ > (match zero_one_valued_p > - (bit_and:c@0 @1 zero_one_valued_p)) > + (bit_and:c@0 @1 integer_onep) > + (if (INTEGRAL_TYPE_P (type)))) > > /* A conversion from an zero_one_valued_p is still a [0,1]. > This is useful when the range of a variable is not known */ > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr111442-1.c b/gcc/tests= uite/gcc.c-torture/compile/pr111442-1.c > new file mode 100644 > index 00000000000..5814ee938de > --- /dev/null > +++ b/gcc/testsuite/gcc.c-torture/compile/pr111442-1.c > @@ -0,0 +1,13 @@ > + > +int *a, b; > +int main() { > + int d =3D 1, e; > + if (d) > + e =3D a ? 0 % 0 : 0; > + if (d) > + a =3D &d; > + d =3D -1; > + b =3D d & e; > + b =3D 2 * e ^ 1; > + return 0; > +} > -- > 2.31.1 >