Message ID | 20230917214055.1752964-1-apinski@marvell.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2310662vqi; Sun, 17 Sep 2023 14:41:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHvCn2xeU9yYdu+yLegj35VOCHS6PkAEqmGqjOFENrfMKmyq5lGz5zMLB+82aok+IDVIaB X-Received: by 2002:a17:906:314b:b0:9ad:e0fb:6edf with SMTP id e11-20020a170906314b00b009ade0fb6edfmr7538311eje.7.1694986919095; Sun, 17 Sep 2023 14:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694986919; cv=none; d=google.com; s=arc-20160816; b=mO8/HPzxWlR8MWrW17TXjOhPT1OxdRbWvEV+8oK/qjGwJwpuw7droCb4ZcQonJH2sy oJ1/NDpRLYtKBg/Uw05oCU8ejVemin1yEGCoLd9cce9zwzpGgW2apD57+XKwgAlIYDRh CIFxF+x+eCYc1SXxrUcC8qZuQpNXB491LX1XoJ/eYOXweQUhB9bzxUOz7MFZtg1azAo9 TGTSMF+lMhljTW/4rOrIuX9sXNmOiwwO7z67adbK+4ArR0D0fXv/Na9KQff2VOfYqEbB n3SsDovm/4shyFmAkD90ylwa75L+q8KZ62AIoIN3babhSfAc6Q/NQSZONc3nwD8UCifW zeBQ== 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 :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mkYU1Bo+FGP67kkZPUs+KoDlxCWMC0m1WV8t2nquBK0=; fh=XbcmRug6/SzczusyoNU1I7Lu5oY0AN2u0mWDzKoxdSs=; b=pfRG2yFdX/Z+zJNDG7FhQlAwWeoYjHtPlMgY3Vz4HTUOny75x7sQrTCeqHhVf6eL7Z X8gvEyE2K7aAfmJwt/9XeWU7GiR7BruouKjqdxbnDowSTzlqeNMbJ5ZELg2P89B1KmCx G7tfy2C3Eoqz3vX/fPGQCC842ddy+okMyQTw11Fpa0zfDxJLmkuMLAjqXvOiOKZ90nL/ i01CqYsYv+YMMRkSAj12Hm083C83GTqTXWuy4kJvEkjn1G0VwZmu2lo0VLVw2eXiMt/y bqCHe+/wZx/D73dRgXs73/MgEFoC5CFatTD9bxE0e/YLKcRSu3UkWuCKeLK2BOKCfG3D Z4PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uRXg0fi2; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f25-20020a170906085900b0099cd32bd549si6691661ejd.606.2023.09.17.14.41.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 14:41:59 -0700 (PDT) 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=uRXg0fi2; 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 97EFE3857353 for <ouuuleilei@gmail.com>; Sun, 17 Sep 2023 21:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97EFE3857353 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694986913; bh=mkYU1Bo+FGP67kkZPUs+KoDlxCWMC0m1WV8t2nquBK0=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=uRXg0fi22H47YVyeyh+46x0uAIwRcS6mL3sHZlpSZbazNDUTuntIQdMfVMnFztBTx UhPC5sQUP7tVbXLxmXehspNVjundjDibfxmcrlUTM0U8GWhkwfa5rNOMWqcAb2+n2m d/XK2F1HVfsNAcd31S04r9yw42qq67KlCgYNLfH4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id B0E243858D32 for <gcc-patches@gcc.gnu.org>; Sun, 17 Sep 2023 21:41:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0E243858D32 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38HLYB53004170 for <gcc-patches@gcc.gnu.org>; Sun, 17 Sep 2023 14:41:09 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3t5bvkj8j9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Sun, 17 Sep 2023 14:41:09 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 17 Sep 2023 14:41:07 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sun, 17 Sep 2023 14:41:07 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 344995C68F6; Sun, 17 Sep 2023 14:41:07 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> CC: Andrew Pinski <apinski@marvell.com> Subject: [PATCH] MATCH: Make zero_one_valued_p non-recusive fully Date: Sun, 17 Sep 2023 14:40:55 -0700 Message-ID: <20230917214055.1752964-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: DybDflu79OOnAzwpyWpbDSfwXCeYUrQO X-Proofpoint-ORIG-GUID: DybDflu79OOnAzwpyWpbDSfwXCeYUrQO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_20,2023-09-15_01,2023-05-22_02 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Andrew Pinski <apinski@marvell.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777322603486886124 X-GMAIL-MSGID: 1777322603486886124 |
Series |
MATCH: Make zero_one_valued_p non-recusive fully
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Andrew Pinski
Sept. 17, 2023, 9:40 p.m. UTC
So it turns out VN can't handle any kind of recusion for match. In this case we have `b = a & -1` and we try to match a as being zero_one_valued_p and VN returns b as being the value and we just go into an infinite loop at this point. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. 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
Comments
On Sun, Sep 17, 2023 at 11:41 PM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > So it turns out VN can't handle any kind of recusion for match. In this > case we have `b = a & -1` and we try to match a as being zero_one_valued_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/testsuite/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 = 1, e; > + if (d) > + e = a ? 0 % 0 : 0; > + if (d) > + a = &d; > + d = -1; > + b = d & e; > + b = 2 * e ^ 1; > + return 0; > +} > -- > 2.31.1 >
On Mon, Sep 18, 2023 at 11:04:16AM +0200, Richard Biener via Gcc-patches wrote: > > 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. s/recusive/recursive/g s/recusion/recursion/g > > 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/testsuite/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 = 1, e; > > + if (d) > > + e = a ? 0 % 0 : 0; > > + if (d) > > + a = &d; > > + d = -1; > > + b = d & e; > > + b = 2 * e ^ 1; > > + return 0; > > +} > > -- > > 2.31.1 > > Jakub
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/testsuite/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 = 1, e; + if (d) + e = a ? 0 % 0 : 0; + if (d) + a = &d; + d = -1; + b = d & e; + b = 2 * e ^ 1; + return 0; +}