From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id ACAE9385840D for ; Wed, 7 Jun 2023 00:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACAE9385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=marvell.com 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 ; Tue, 6 Jun 2023 17:17:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=cBeDqA/mmI04iQGt1fqg9mE+YfTg2bwf5pjSq7bbpEg=; b=eHaD2wJtb/6BJouanSTKfqCTvt9zAId3VLKd88LFbBrmey6AAcpeL+n95wZj+YqBgyKI 6g7OAi3sRGOlw7a8FuwR+/WxglvCmHlHg1sE6fiF/i3J/rzPrTYt5USpVlnMH/JwFWRh +0MxDJiOGI2GK0bQUKqbexOA+Xsx36qtrHzKoq6+dNWCavJAAcoSMySqBC9X+JdQXlA6 gE3O9rRAuMesYYlpt/6zU+7fKE5var5xm0Uw6TwBJyXxyw96aCBmvL3LWCpMyJ6vyhFK 6b+a9j3AdvSSUOanCVb4jGVmPFXjWyfxcsTry+S5vJIEExRFrJtGKZ+rNsSrNntWINRn pQ== 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 ; 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) From: Andrew Pinski To: CC: Andrew Pinski 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 List-Id: 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))) (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 -- 2.31.1