On Sat, 26 Oct 2024, Richard Biener wrote:

> With the intent to rely on vec_cond_mask and vec_cmp patterns
> comparisons do not need rewriting into COND_EXPRs that eventually
> combine to vec_cond{u,eq,}.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.

So with this I effectively removed all invocations of adjust_bool_stmts
since there's no path left in check_bool_pattern that would ever
end up populating the set of stmts to rewrite.

What is surprising is that there's no test coverage (or no
regressions) for the optimizations attempted by adjust_bool_stmts
though those were written with sequences of COND_EXPRs in mind.

I'll post a patch removing the code next.

Richard.

>       * tree-vect-patterns.cc (check_bool_pattern): For comparisons
>       we do nothing if we can expand them or we can't replace them
>       with a ? -1 : 0 condition - but the latter would require
>       expanding the comparison which we proved we can't.  So do
>       nothing, aka not think vec_cond{u,eq,} will save us.
> ---
>  gcc/tree-vect-patterns.cc | 37 +------------------------------------
>  1 file changed, 1 insertion(+), 36 deletions(-)
> 
> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> index 46aa3129bb3..a6d246f570c 100644
> --- a/gcc/tree-vect-patterns.cc
> +++ b/gcc/tree-vect-patterns.cc
> @@ -5610,42 +5610,7 @@ check_bool_pattern (tree var, vec_info *vinfo, 
> hash_set<gimple *> &stmts)
>        break;
>  
>      default:
> -      if (TREE_CODE_CLASS (rhs_code) == tcc_comparison)
> -     {
> -       tree vecitype, comp_vectype;
> -
> -       /* If the comparison can throw, then is_gimple_condexpr will be
> -          false and we can't make a COND_EXPR/VEC_COND_EXPR out of it.  */
> -       if (stmt_could_throw_p (cfun, def_stmt))
> -         return false;
> -
> -       comp_vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (rhs1));
> -       if (comp_vectype == NULL_TREE)
> -         return false;
> -
> -       tree mask_type = get_mask_type_for_scalar_type (vinfo,
> -                                                       TREE_TYPE (rhs1));
> -       if (mask_type
> -           && expand_vec_cmp_expr_p (comp_vectype, mask_type, rhs_code))
> -         return false;
> -
> -       if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE)
> -         {
> -           scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1));
> -           tree itype
> -             = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1);
> -           vecitype = get_vectype_for_scalar_type (vinfo, itype);
> -           if (vecitype == NULL_TREE)
> -             return false;
> -         }
> -       else
> -         vecitype = comp_vectype;
> -       if (! expand_vec_cond_expr_p (vecitype, comp_vectype, rhs_code))
> -         return false;
> -     }
> -      else
> -     return false;
> -      break;
> +      return false;
>      }
>  
>    bool res = stmts.add (def_stmt);
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to