On Mon, Jul 31, 2023 at 7:47 PM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This slighly improves bitwise_inverted_equal_p
> for comparisons. Instead of just comparing the
> comparisons operands also valueize them.
> This will allow ccp and others to match the 2 comparisons
> without an extra pass happening.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu.

OK.

> gcc/ChangeLog:
>
>         * gimple-match-head.cc (gimple_bitwise_inverted_equal_p): Valueize
>         the comparison operands before comparing them.
> ---
>  gcc/gimple-match-head.cc | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
> index 0265e55be93..b1e96304d7c 100644
> --- a/gcc/gimple-match-head.cc
> +++ b/gcc/gimple-match-head.cc
> @@ -319,12 +319,12 @@ gimple_bitwise_inverted_equal_p (tree expr1, tree 
> expr2, tree (*valueize) (tree)
>        && TREE_CODE_CLASS (gimple_assign_rhs_code (a1)) == tcc_comparison
>        && TREE_CODE_CLASS (gimple_assign_rhs_code (a2)) == tcc_comparison)
>      {
> -      tree op10 = gimple_assign_rhs1 (a1);
> -      tree op20 = gimple_assign_rhs1 (a2);
> +      tree op10 = do_valueize (valueize, gimple_assign_rhs1 (a1));
> +      tree op20 = do_valueize (valueize, gimple_assign_rhs1 (a2));
>        if (!operand_equal_p (op10, op20))
>          return false;
> -      tree op11 = gimple_assign_rhs2 (a1);
> -      tree op21 = gimple_assign_rhs2 (a2);
> +      tree op11 = do_valueize (valueize, gimple_assign_rhs2 (a1));
> +      tree op21 = do_valueize (valueize, gimple_assign_rhs2 (a2));
>        if (!operand_equal_p (op11, op21))
>          return false;
>        if (invert_tree_comparison (gimple_assign_rhs_code (a1),
> --
> 2.31.1
>

Reply via email to