Add an is_narrower_int_mode helper function

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.

2017-11-01  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@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.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r254305
This commit is contained in:
Richard Sandiford 2017-11-01 13:30:34 +00:00 committed by Richard Sandiford
parent b3ad445f85
commit 7aaba298fe
4 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2017-11-01 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* machmode.h (is_narrower_int_mode): New function
* optabs.c (expand_float, expand_fix): Use it.
* dwarf2out.c (rotate_loc_descriptor): Likewise.
2017-11-01 Richard Sandiford <richard.sandiford@linaro.org> 2017-11-01 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>

View File

@ -14547,8 +14547,7 @@ rotate_loc_descriptor (rtx rtl, scalar_int_mode mode,
dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL };
int i; int i;
if (GET_MODE (rtlop1) != VOIDmode if (is_narrower_int_mode (GET_MODE (rtlop1), mode))
&& GET_MODE_BITSIZE (GET_MODE (rtlop1)) < GET_MODE_BITSIZE (mode))
rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1);
op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode,
VAR_INIT_STATUS_INITIALIZED); VAR_INIT_STATUS_INITIALIZED);

View File

@ -893,6 +893,17 @@ is_complex_float_mode (machine_mode mode, T *cmode)
return false; 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 namespace mode_iterator
{ {
/* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */

View File

@ -4811,7 +4811,7 @@ expand_float (rtx to, rtx from, int unsignedp)
rtx value; rtx value;
convert_optab tab = unsignedp ? ufloat_optab : sfloat_optab; 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); from = convert_to_mode (SImode, from, unsignedp);
libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from)); libfunc = convert_optab_libfunc (tab, GET_MODE (to), GET_MODE (from));
@ -4993,7 +4993,7 @@ expand_fix (rtx to, rtx from, int unsignedp)
that the mode of TO is at least as wide as SImode, since those are the that the mode of TO is at least as wide as SImode, since those are the
only library calls we know about. */ 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); target = gen_reg_rtx (SImode);