[49/77] Simplify nonzero/num_sign_bits hooks

The two implementations of the reg_nonzero_bits and reg_num_sign_bits
hooks ignored the "known_x", "known_mode" and "known_ret" arguments,
so this patch removes them.  It adds a new scalar_int_mode parameter
that specifies the mode of "x".  (This mode might be different from
"mode", which is the mode in which "x" is used.)

2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode
	parameter for the mode of "x".  Remove the "known_x", "known_mode"
	and "known_ret" arguments.  Change the type of the mode argument
	to scalar_int_mode.
	(rtl_hooks:reg_num_sign_bit_copies): Likewise.
	* combine.c (reg_nonzero_bits_for_combine): Update accordingly.
	(reg_num_sign_bit_copies_for_combine): Likewise.
	* rtlanal.c (nonzero_bits1): Likewise.
	(num_sign_bit_copies1): Likewise.
	* rtlhooks-def.h (reg_nonzero_bits_general): Likewise.
	(reg_num_sign_bit_copies_general): Likewise.
	* rtlhooks.c (reg_num_sign_bit_copies_general): Likewise.
	(reg_nonzero_bits_general): Likewise.

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

From-SVN: r251501
This commit is contained in:
Richard Sandiford 2017-08-30 11:17:12 +00:00 committed by Richard Sandiford
parent f8265fb8e8
commit 401581b6eb
6 changed files with 52 additions and 53 deletions

View File

@ -1,3 +1,21 @@
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode
parameter for the mode of "x". Remove the "known_x", "known_mode"
and "known_ret" arguments. Change the type of the mode argument
to scalar_int_mode.
(rtl_hooks:reg_num_sign_bit_copies): Likewise.
* combine.c (reg_nonzero_bits_for_combine): Update accordingly.
(reg_num_sign_bit_copies_for_combine): Likewise.
* rtlanal.c (nonzero_bits1): Likewise.
(num_sign_bit_copies1): Likewise.
* rtlhooks-def.h (reg_nonzero_bits_general): Likewise.
(reg_num_sign_bit_copies_general): Likewise.
* rtlhooks.c (reg_num_sign_bit_copies_general): Likewise.
(reg_nonzero_bits_general): Likewise.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> 2017-08-30 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

@ -414,13 +414,12 @@ static struct undobuf undobuf;
static int n_occurrences; static int n_occurrences;
static rtx reg_nonzero_bits_for_combine (const_rtx, machine_mode, const_rtx, static rtx reg_nonzero_bits_for_combine (const_rtx, scalar_int_mode,
machine_mode, scalar_int_mode,
unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT *); unsigned HOST_WIDE_INT *);
static rtx reg_num_sign_bit_copies_for_combine (const_rtx, machine_mode, const_rtx, static rtx reg_num_sign_bit_copies_for_combine (const_rtx, scalar_int_mode,
machine_mode, scalar_int_mode,
unsigned int, unsigned int *); unsigned int *);
static void do_SUBST (rtx *, rtx); static void do_SUBST (rtx *, rtx);
static void do_SUBST_INT (int *, int); static void do_SUBST_INT (int *, int);
static void init_reg_last (void); static void init_reg_last (void);
@ -10035,17 +10034,15 @@ simplify_and_const_int (rtx x, scalar_int_mode mode, rtx varop,
return x; return x;
} }
/* Given a REG, X, compute which bits in X can be nonzero. /* Given a REG X of mode XMODE, compute which bits in X can be nonzero.
We don't care about bits outside of those defined in MODE. We don't care about bits outside of those defined in MODE.
For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is
a shift, AND, or zero_extract, we can do better. */ a shift, AND, or zero_extract, we can do better. */
static rtx static rtx
reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode, reg_nonzero_bits_for_combine (const_rtx x, scalar_int_mode xmode,
const_rtx known_x ATTRIBUTE_UNUSED, scalar_int_mode mode,
machine_mode known_mode ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT *nonzero) unsigned HOST_WIDE_INT *nonzero)
{ {
rtx tem; rtx tem;
@ -10086,8 +10083,7 @@ reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode,
if (tem) if (tem)
{ {
if (SHORT_IMMEDIATES_SIGN_EXTEND) if (SHORT_IMMEDIATES_SIGN_EXTEND)
tem = sign_extend_short_imm (tem, GET_MODE (x), tem = sign_extend_short_imm (tem, xmode, GET_MODE_PRECISION (mode));
GET_MODE_PRECISION (mode));
return tem; return tem;
} }
@ -10096,9 +10092,9 @@ reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode,
{ {
unsigned HOST_WIDE_INT mask = rsp->nonzero_bits; unsigned HOST_WIDE_INT mask = rsp->nonzero_bits;
if (GET_MODE_PRECISION (GET_MODE (x)) < GET_MODE_PRECISION (mode)) if (GET_MODE_PRECISION (xmode) < GET_MODE_PRECISION (mode))
/* We don't know anything about the upper bits. */ /* We don't know anything about the upper bits. */
mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (GET_MODE (x)); mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (xmode);
*nonzero &= mask; *nonzero &= mask;
} }
@ -10106,17 +10102,14 @@ reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode,
return NULL; return NULL;
} }
/* Return the number of bits at the high-order end of X that are known to /* Given a reg X of mode XMODE, return the number of bits at the high-order
be equal to the sign bit. X will be used in mode MODE; if MODE is end of X that are known to be equal to the sign bit. X will be used
VOIDmode, X will be used in its own mode. The returned value will always in mode MODE; the returned value will always be between 1 and the
be between 1 and the number of bits in MODE. */ number of bits in MODE. */
static rtx static rtx
reg_num_sign_bit_copies_for_combine (const_rtx x, machine_mode mode, reg_num_sign_bit_copies_for_combine (const_rtx x, scalar_int_mode xmode,
const_rtx known_x ATTRIBUTE_UNUSED, scalar_int_mode mode,
machine_mode known_mode
ATTRIBUTE_UNUSED,
unsigned int known_ret ATTRIBUTE_UNUSED,
unsigned int *result) unsigned int *result)
{ {
rtx tem; rtx tem;
@ -10145,7 +10138,7 @@ reg_num_sign_bit_copies_for_combine (const_rtx x, machine_mode mode,
return tem; return tem;
if (nonzero_sign_valid && rsp->sign_bit_copies != 0 if (nonzero_sign_valid && rsp->sign_bit_copies != 0
&& GET_MODE_PRECISION (GET_MODE (x)) == GET_MODE_PRECISION (mode)) && GET_MODE_PRECISION (xmode) == GET_MODE_PRECISION (mode))
*result = rsp->sign_bit_copies; *result = rsp->sign_bit_copies;
return NULL; return NULL;

View File

@ -3779,10 +3779,10 @@ struct rtl_hooks
{ {
rtx (*gen_lowpart) (machine_mode, rtx); rtx (*gen_lowpart) (machine_mode, rtx);
rtx (*gen_lowpart_no_emit) (machine_mode, rtx); rtx (*gen_lowpart_no_emit) (machine_mode, rtx);
rtx (*reg_nonzero_bits) (const_rtx, machine_mode, const_rtx, machine_mode, rtx (*reg_nonzero_bits) (const_rtx, scalar_int_mode, scalar_int_mode,
unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); unsigned HOST_WIDE_INT *);
rtx (*reg_num_sign_bit_copies) (const_rtx, machine_mode, const_rtx, machine_mode, rtx (*reg_num_sign_bit_copies) (const_rtx, scalar_int_mode, scalar_int_mode,
unsigned int, unsigned int *); unsigned int *);
bool (*reg_truncated_to_mode) (machine_mode, const_rtx); bool (*reg_truncated_to_mode) (machine_mode, const_rtx);
/* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */ /* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */

View File

@ -4449,8 +4449,7 @@ nonzero_bits1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
{ {
unsigned HOST_WIDE_INT nonzero_for_hook = nonzero; unsigned HOST_WIDE_INT nonzero_for_hook = nonzero;
rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, mode, known_x, rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, xmode, mode,
known_mode, known_ret,
&nonzero_for_hook); &nonzero_for_hook);
if (new_rtx) if (new_rtx)
@ -4943,8 +4942,7 @@ num_sign_bit_copies1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
{ {
unsigned int copies_for_hook = 1, copies = 1; unsigned int copies_for_hook = 1, copies = 1;
rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, mode, known_x, rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, xmode, mode,
known_mode, known_ret,
&copies_for_hook); &copies_for_hook);
if (new_rtx) if (new_rtx)

View File

@ -38,13 +38,11 @@ along with GCC; see the file COPYING3. If not see
} }
extern rtx gen_lowpart_general (machine_mode, rtx); extern rtx gen_lowpart_general (machine_mode, rtx);
extern rtx reg_nonzero_bits_general (const_rtx, machine_mode, const_rtx, extern rtx reg_nonzero_bits_general (const_rtx, scalar_int_mode,
machine_mode, scalar_int_mode,
unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT *); unsigned HOST_WIDE_INT *);
extern rtx reg_num_sign_bit_copies_general (const_rtx, machine_mode, const_rtx, extern rtx reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode,
machine_mode, scalar_int_mode, unsigned int *);
unsigned int, unsigned int *);
extern bool reg_truncated_to_mode_general (machine_mode, const_rtx); extern bool reg_truncated_to_mode_general (machine_mode, const_rtx);
#endif /* GCC_RTL_HOOKS_DEF_H */ #endif /* GCC_RTL_HOOKS_DEF_H */

View File

@ -86,23 +86,15 @@ gen_lowpart_general (machine_mode mode, rtx x)
} }
rtx rtx
reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED, reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, scalar_int_mode,
machine_mode mode ATTRIBUTE_UNUSED, unsigned int *)
const_rtx known_x ATTRIBUTE_UNUSED,
machine_mode known_mode ATTRIBUTE_UNUSED,
unsigned int known_ret ATTRIBUTE_UNUSED,
unsigned int *result ATTRIBUTE_UNUSED)
{ {
return NULL; return NULL;
} }
rtx rtx
reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED, reg_nonzero_bits_general (const_rtx, scalar_int_mode, scalar_int_mode,
machine_mode mode ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT *)
const_rtx known_x ATTRIBUTE_UNUSED,
machine_mode known_mode ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
{ {
return NULL; return NULL;
} }