From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id F3961385840D; Wed, 7 Jun 2023 02:43:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3961385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686105831; bh=lNALdNBUBgabMKJD/tdFVowAmqwTu1KB/Q+cN7PdwJc=; h=From:To:Subject:Date:From; b=ahOkGhKVcK5NEQEJfJuDEtY7mlehiZK7YJqA49g/lawRK9DY8ecEywbp5Ip/CBf3N 1mJZ/qTlLpZelsZRuPUb8wZHlgJXHjulwLpthy8yElDOWe/Ua4TxBHjK1quK+JXYL1 iYWAHMj1z9SLOnOpdSPEKXiGgA+0jwKWzB0A+SGc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1596] Match: zero_one_valued_p should match 0 constants too X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 42eb371286fa4f1f8419ff9e8059576e574c7a2c X-Git-Newrev: c5c4fa2f9a448d529be746119ebca4fc5e5701b2 Message-Id: <20230607024350.F3961385840D@sourceware.org> Date: Wed, 7 Jun 2023 02:43:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c5c4fa2f9a448d529be746119ebca4fc5e5701b2 commit r14-1596-gc5c4fa2f9a448d529be746119ebca4fc5e5701b2 Author: Andrew Pinski Date: Tue Jun 6 08:21:46 2023 -0700 Match: zero_one_valued_p should match 0 constants too 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. Diff: --- gcc/match.pd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index 16482b741ea..7bb7413ff65 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