On Mon, Oct 23, 2017 at 1:24 PM, Richard Sandiford
<richard.sandif...@linaro.org> wrote:
> This patch adds a function for testing whether an arbitrary mode X
> is an integer mode that is narrower than integer mode Y.  This is
> useful for code like expand_float and expand_fix that could in
> principle handle vectors as well as scalars.

Ok.

Richard.

>
> 2017-10-23  Richard Sandiford  <richard.sandif...@linaro.org>
>             Alan Hayward  <alan.hayw...@arm.com>
>             David Sherwood  <david.sherw...@arm.com>
>
> gcc/
>         * machmode.h (is_narrower_int_mode): New function
>         * optabs.c (expand_float, expand_fix): Use it.
>         * dwarf2out.c (rotate_loc_descriptor): Likewise.
>
> Index: gcc/machmode.h
> ===================================================================
> --- gcc/machmode.h      2017-10-23 11:44:06.561720156 +0100
> +++ gcc/machmode.h      2017-10-23 11:44:23.979432614 +0100
> @@ -893,6 +893,17 @@ is_complex_float_mode (machine_mode mode
>    return false;
>  }
>
> +/* Return true if MODE is a scalar integer mode with a precision
> +   smaller than LIMIT's precision.  */
> +
> +inline bool
> +is_narrower_int_mode (machine_mode mode, scalar_int_mode limit)
> +{
> +  scalar_int_mode int_mode;
> +  return (is_a <scalar_int_mode> (mode, &int_mode)
> +         && GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (limit));
> +}
> +
>  namespace mode_iterator
>  {
>    /* Start mode iterator *ITER at the first mode in class MCLASS, if any.  */
> Index: gcc/optabs.c
> ===================================================================
> --- gcc/optabs.c        2017-10-23 11:44:07.732431531 +0100
> +++ gcc/optabs.c        2017-10-23 11:44:23.980398548 +0100
> @@ -4820,7 +4820,7 @@ expand_float (rtx to, rtx from, int unsi
>        rtx value;
>        convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab;
>
> -      if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_PRECISION (SImode))
> +      if (is_narrower_int_mode (GET_MODE (from), SImode))
>         from = convert_to_mode (SImode, from, unsignedp);
>
>        libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from));
> @@ -5002,7 +5002,7 @@ expand_fix (rtx to, rtx from, int unsign
>       that the mode of TO is at least as wide as SImode, since those are the
>       only library calls we know about.  */
>
> -  if (GET_MODE_PRECISION (GET_MODE (to)) < GET_MODE_PRECISION (SImode))
> +  if (is_narrower_int_mode (GET_MODE (to), SImode))
>      {
>        target = gen_reg_rtx (SImode);
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     2017-10-23 11:44:05.684652559 +0100
> +++ gcc/dwarf2out.c     2017-10-23 11:44:23.979432614 +0100
> @@ -14530,8 +14530,7 @@ rotate_loc_descriptor (rtx rtl, scalar_i
>    dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL };
>    int i;
>
> -  if (GET_MODE (rtlop1) != VOIDmode
> -      && GET_MODE_BITSIZE (GET_MODE (rtlop1)) < GET_MODE_BITSIZE (mode))
> +  if (is_narrower_int_mode (GET_MODE (rtlop1), mode))
>      rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1);
>    op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
>                             VAR_INIT_STATUS_INITIALIZED);

Reply via email to