Message ID | 20230607001706.3000011-1-apinski@marvell.com |
---|---|
State | Committed |
Commit | c5c4fa2f9a448d529be746119ebca4fc5e5701b2 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 181223857341 for <patchwork@sourceware.org>; Wed, 7 Jun 2023 00:18:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 181223857341 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686097087; 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=Z5IQynY/7vImfl8wUB3YKYpUuMuP3JaHm4GjadnNCmTEgl3Ol6zKobggI5cWCCRq6 KNo4nHbNiTK92YdxlUcNv2nv/QwAGzJKHf9hK99VgcZjpSJX7v/BlqQjq65/LmxOjJ r55mMQSRuFCxIHhM8tCm8g3JQeQ9N8Jpkp6iatGU= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[1/2] Match: zero_one_valued_p should match 0 constants too
|
|
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