]> gcc.gnu.org Git - gcc.git/commitdiff
match.pd: Improve zero_one_valued_p
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 Jun 2023 17:18:26 +0000 (19:18 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 7 Jun 2023 17:18:26 +0000 (19:18 +0200)
Recently zero_one_valued_p was changed to handle integer_zerop
case specially, because tree_nonzero_bits (@0) == 1 only returns
true for non-constant values with range [0, 1] or constant 1,
constant 0 has tree_nonzero_bits (integer_zero_node) == 0.

The following patch reverts that change and instead checks
that tree_nonzero_bits is <= 1U.

2023-06-07  Jakub Jelinek  <jakub@redhat.com>

* match.pd (zero_one_valued_p): Don't handle integer_zerop specially,
instead compare tree_nonzero_bits <= 1U rather than just == 1.

gcc/match.pd

index dc36927cd0f045eb80c416d88ee25115c75df70e..fd32389decfb205b2ff17c9e38d1ecf723115573 100644 (file)
@@ -1984,15 +1984,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   @0)
 
 /* zero_one_valued_p will match when a value is known to be either
-   0 or 1 including the constant 0. */
+   0 or 1 including constants 0 or 1. */
 (match zero_one_valued_p
  @0
- (if (INTEGRAL_TYPE_P (type) && tree_nonzero_bits (@0) == 1)))
+ (if (INTEGRAL_TYPE_P (type) && 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
This page took 0.063886 seconds and 5 git commands to generate.