On Wed, Nov 19, 2025 at 03:07:52PM +0100, Richard Biener wrote:
> > --- a/gcc/match.pd
> > +++ b/gcc/match.pd
> > @@ -1339,37 +1339,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> >      (if (INTEGRAL_TYPE_P (type))
> >        (rshift (op @0 @2) @1))))
> >  
> > -/* (y << x) == x -> 0 when y != 0.  */
> > +/* (y << x) == x -> false when y != 0.  */
> >  (simplify
> >    (eq:c (nop_convert1? (lshift @0 @1)) (nop_convert2? @1))
> >    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> >         && tree_expr_nonzero_p (@0))
> > -   { build_zero_cst (type); }))
> > -
> > -/* (y << x) {<,<=} x -> 0 when y > 0.  */
> > -(for cmp (lt le)
> > -  (simplify
> > -    (cmp:c (nop_convert1? (lshift @0 @1)) (nop_convert2? @1))
> > -    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> > -    && tree_expr_nonzero_p (@0)
> > -    && tree_expr_nonnegative_p (@0))
> > -     { build_zero_cst (type); })))
> > +   { constant_boolean_node (false, type); }))
> >  
> > -/* (y << x) != x -> 1 when y != 0.  */
> > +/* (y << x) != x -> true when y != 0.  */
> >  (simplify
> >    (ne:c (nop_convert1? (lshift @0 @1)) (nop_convert2? @1))
> >    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> >         && tree_expr_nonzero_p (@0))
> > -   { build_one_cst (type); }))
> > -
> > -/* (y << x) {>,>=} x -> 1 when y > 0.  */
> > -(for cmp (gt ge)
> > -  (simplify
> > -    (cmp:c (nop_convert1? (lshift @0 @1)) (nop_convert2? @1))
> > -    (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
> > -    && tree_expr_nonzero_p (@0)
> > -    && tree_expr_nonnegative_p (@0))
> > -     { build_one_cst (type); })))
> > +   { constant_boolean_node (true, type); }))

>From maintainance POV, wonder why these 2 remaining patterns aren't
just one with
(for cmp (eq ne)
and constant_boolean_node (cmp != EQ_EXPR, type) or something like that.

        Jakub

Reply via email to