On Thu, May 24, 2018 at 09:21:35AM +0100, Richard Sandiford wrote:
> vect_recog_divmod_pattern currently bails out if the target has
> native support for integer division, but I think in practice
> it's always going to be better to open-code it anyway, just as
> we usually open-code scalar divisions by constants.
> 
> I think the only currently affected target is MIPS MSA, where for:

Isn't powerpcspe affected too?  It has a divv2si3 pattern.

> --- gcc/tree-vect-patterns.c  2018-05-16 12:48:59.115202362 +0100
> +++ gcc/tree-vect-patterns.c  2018-05-24 09:18:10.445466941 +0100
> @@ -2639,7 +2639,6 @@ vect_recog_divmod_pattern (vec<gimple *>
>    enum tree_code rhs_code;
>    stmt_vec_info stmt_vinfo = vinfo_for_stmt (last_stmt);
>    vec_info *vinfo = stmt_vinfo->vinfo;
> -  optab optab;
>    tree q;
>    int dummy_int, prec;
>    stmt_vec_info def_stmt_vinfo;
> @@ -2674,17 +2673,6 @@ vect_recog_divmod_pattern (vec<gimple *>
>    if (vectype == NULL_TREE)
>      return NULL;
>  
> -  /* If the target can handle vectorized division or modulo natively,
> -     don't attempt to optimize this.  */
> -  optab = optab_for_tree_code (rhs_code, vectype, optab_default);
> -  if (optab != unknown_optab)
> -    {
> -      machine_mode vec_mode = TYPE_MODE (vectype);
> -      int icode = (int) optab_handler (optab, vec_mode);
> -      if (icode != CODE_FOR_nothing)
> -     return NULL;
> -    }
> -

Shouldn't we instead keep it, but only do it if
optimize_bb_for_size_p (gimple_bb (last_stmt)) ?
I mean, a hw division is very likely shorter than what we replace it with...

        Jakub

Reply via email to