On Wed, Nov 19, 2025 at 08:39:48PM +0530, Dhruv Chawla wrote:
> Ah, I didn't even think of that, good catch. I've attached an updated patch,
> does it look okay?

> Signed-off-by: Dhruv Chawla <[email protected]>
> 
>       PR tree-optimization/122733
> 
> gcc/ChangeLog:
> 
>       * match.pd: Remove patterns. Also call constant_boolean_node instead of

Usually one specifies the match.pd entities with (parts of) the
transformation comments, so I'd say:
        * match.pd ((y << x) {<,<=,>,>=} x): Remove.
        ((y << x) == x, (y << x) != x): Merge into a single pattern
        with iterator.

> +/* (y << x) == x -> false and (y << x) != x -> true when y != 0.  */
> +(for cmp (eq ne)
>    (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); })))
> +      && tree_expr_nonzero_p (@0))
> +     { constant_boolean_node (cmp != EQ_EXPR, type); })))

I think the normal match.pd indentation is by 1 column instead of 2,
so
(for cmp (eq ne)
 (simplify
  (cmp:c (nop_convert1? (lshift @0 @1)) (nop_convert2? @1))
  (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
       && tree_expr_nonzero_p (@0))
   { constant_boolean_node (cmp != EQ_EXPR, type); })))

Otherwise LGTM.

        Jakub

Reply via email to