Message ID | 20230607001706.3000011-1-apinski@marvell.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3754198vqr; Tue, 6 Jun 2023 17:18:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/DDXLU+0A8L1/yG11CC7w2HHPm7ku3V1ZQmZaGUpO1qDG6UHE9e7P73TP6U3Lxui1oOXY X-Received: by 2002:aa7:d783:0:b0:514:7edc:4420 with SMTP id s3-20020aa7d783000000b005147edc4420mr2955548edq.16.1686097121298; Tue, 06 Jun 2023 17:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686097121; cv=none; d=google.com; s=arc-20160816; b=aE/G0YDgT/YX/fgB2/ZNsoyZ0WxdcG2Cb2wgOJLYSY/8Mx54E5krp+mjdup4atq+zd Ox+LZrrlTiKe33LuzrU5yYYYRssVHNFIsuwrAL30n4kT/1gGhILM7EueCxDzDYlB+zwQ 3pbEsSBHORU6+Zdg9mD8U0v0kELwby4tHa7g2Hdq1sKos7hjDWJirlznaJfM3EsQeFDT brzrjpfAk/A6h2tMsYIW9qzp2YBx0HYsysWNprR3hULRMJkk8EWFGZcnI2ywB4ffslbI iSoVaLNnotzsY0e2a2ImBA/cxOnYtorJBlZrJm5IQmYEoT7QOy44CVexN2YA5JWM5ckn CJ6Q== 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=cBeDqA/mmI04iQGt1fqg9mE+YfTg2bwf5pjSq7bbpEg=; b=ELoYsy1iZPuGUKC1vUsWrVoApsrUHGJPAAAq69tzJ+stG5cwJ1SX4lK1me1O2FULW2 xGu7pE6rRTRRArXKfR77s6idLdBIPSzN1iM2O6CtP5eGeLho89lfB5smHYuXB8aiqSMj Fmnh9gb5DneFQAG16XPZGRFm7egf8qlp7zQDUamCTQ/vrXJ61c6HTFSm6f1iXg8FVtxA 8yEgYbv30pMMROMpzbKoV5+CE1CJ4rMsQU7A6IsG6rGF+1mAmhSz3zfIFWccgaAIh9p4 LFBVM8YgNX2pdAOBce5a50Bg91gJAh64ee0wCQFa6Nb3no+CPqXXvi2tvlr9wJ/96wsE l4YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EWOmTalk; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r4-20020aa7cfc4000000b0051611e7ad57si8147028edy.597.2023.06.06.17.18.41 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 17:18:41 -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=EWOmTalk; 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 7B5533857B9B for <ouuuleilei@gmail.com>; Wed, 7 Jun 2023 00:18:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B5533857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686097109; bh=cBeDqA/mmI04iQGt1fqg9mE+YfTg2bwf5pjSq7bbpEg=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=EWOmTalkmmakdUWaubUmfu5G54X0ELKX944KcsOMSAWHPj74n0H0CoQ3a91Ugoiag KThc1WHcs8zYMkC5Kzf3Qg+KGoSGAKpPuR6TIxWDDvW3t/09V/qDn/gsR5jBFVZ2GC aVbrU2BI6bjr2FSt41vuPcUU2QEtbZXe65FskuG8= 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 ACAE9385840D for <gcc-patches@gcc.gnu.org>; Wed, 7 Jun 2023 00:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACAE9385840D 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 356Lol8i001794 for <gcc-patches@gcc.gnu.org>; Tue, 6 Jun 2023 17:17:17 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3r2a758ufg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Tue, 06 Jun 2023 17:17:17 -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; Tue, 6 Jun 2023 17:17:14 -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; Tue, 6 Jun 2023 17:17:14 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id B09493F708C; Tue, 6 Jun 2023 17:17:14 -0700 (PDT) To: <gcc-patches@gcc.gnu.org> CC: Andrew Pinski <apinski@marvell.com> Subject: [PATCH 1/2] Match: zero_one_valued_p should match 0 constants too Date: Tue, 6 Jun 2023 17:17:05 -0700 Message-ID: <20230607001706.3000011-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-ORIG-GUID: yeSg7a1EImtb4ZlD14oXq3sA7gvtfCub X-Proofpoint-GUID: yeSg7a1EImtb4ZlD14oXq3sA7gvtfCub X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_18,2023-06-06_02,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, T_SCC_BODY_TEXT_LINE 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 <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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768000975488310094?= X-GMAIL-MSGID: =?utf-8?q?1768000975488310094?= |
Series |
[1/2] Match: zero_one_valued_p should match 0 constants too
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Andrew Pinski
June 7, 2023, 12:17 a.m. UTC
While working on `bool0 ? bool1 : bool2` I noticed that zero_one_valued_p does not match on the constant zero as in that case tree_nonzero_bits will return 0 and that is different from 1. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (zero_one_valued_p): Match 0 integer constant too. --- gcc/match.pd | 5 +++++ 1 file changed, 5 insertions(+)
Comments
On 6/6/23 18:17, Andrew Pinski via Gcc-patches wrote: > While working on `bool0 ? bool1 : bool2` I noticed that > zero_one_valued_p does not match on the constant zero > as in that case tree_nonzero_bits will return 0 and > that is different from 1. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > gcc/ChangeLog: > > * match.pd (zero_one_valued_p): Match 0 integer constant > too. Presumably "1" is matched by the tree_nonzero_bits (@0) == 1. So OK. jeff
On Tue, Jun 06, 2023 at 05:17:05PM -0700, Andrew Pinski via Gcc-patches wrote: > While working on `bool0 ? bool1 : bool2` I noticed that > zero_one_valued_p does not match on the constant zero > as in that case tree_nonzero_bits will return 0 and > that is different from 1. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > gcc/ChangeLog: > > * match.pd (zero_one_valued_p): Match 0 integer constant > too. > --- > gcc/match.pd | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/gcc/match.pd b/gcc/match.pd > index f9cbd757752..f97ff7ef760 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -1983,11 +1983,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (bit_not (bit_not @0)) > @0) > > +/* zero_one_valued_p will match when a value is known to be either > + 0 or 1 including the constant 0. */ > (match zero_one_valued_p > @0 > (if (INTEGRAL_TYPE_P (type) && tree_nonzero_bits (@0) == 1))) So perhaps instead change this to && wi::leu_p (tree_nonzero_bits (@0), 1) ? > (match zero_one_valued_p > truth_valued_p@0) > +(match zero_one_valued_p > + integer_zerop@0 > + (if (INTEGRAL_TYPE_P (type)))) > > /* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 }. */ > (simplify Jakub
On 6/7/23 01:12, Jakub Jelinek via Gcc-patches wrote: >> >> +/* zero_one_valued_p will match when a value is known to be either >> + 0 or 1 including the constant 0. */ >> (match zero_one_valued_p >> @0 >> (if (INTEGRAL_TYPE_P (type) && tree_nonzero_bits (@0) == 1))) > > So perhaps instead change this to > && wi::leu_p (tree_nonzero_bits (@0), 1) I guess that would cover both cases without the extra conditional. I'm fine with that approach too. Consider it pre-approved if someone wants to make that change. jeff
diff --git a/gcc/match.pd b/gcc/match.pd index f9cbd757752..f97ff7ef760 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1983,11 +1983,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_not (bit_not @0)) @0) +/* zero_one_valued_p will match when a value is known to be either + 0 or 1 including the constant 0. */ (match zero_one_valued_p @0 (if (INTEGRAL_TYPE_P (type) && tree_nonzero_bits (@0) == 1))) (match zero_one_valued_p truth_valued_p@0) +(match zero_one_valued_p + integer_zerop@0 + (if (INTEGRAL_TYPE_P (type)))) /* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 }. */ (simplify