Make more use of end_hard_regno

An upcoming patch will convert hard_regno_nregs into an inline
function, which in turn allows hard_regno_nregs to be used as the
name of a targetm field.  This patch rewrites uses that can use
end_hard_regno instead.

2017-09-12  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* config/aarch64/aarch64.c (aarch64_hard_regno_mode_ok): Use
	end_hard_regno instead of hard_regno_nregs.
	* config/s390/s390.c (s390_reg_clobbered_rtx): Likewise.
	* config/sparc/sparc.h (ASM_DECLARE_REGISTER_GLOBAL): Likewise.
	* config/visium/visium.c (visium_hard_regno_mode_ok): Likewise.
	* ira-color.c (improve_allocation): Likewise.
	* lra-assigns.c (find_hard_regno_for_1): Likewise.
	* lra-lives.c (mark_regno_live): Likewise.
	(mark_regno_dead): Likewise.
	* lra-remat.c (operand_to_remat): Likewise.
	* lra.c (collect_non_operand_hard_regs): Likewise.
	* postreload.c (reload_combine_note_store): Likewise.
	(move2add_valid_value_p): Likewise.
	* reload.c (regno_clobbered_p): Likewise.

From-SVN: r252012
This commit is contained in:
Richard Sandiford 2017-09-12 13:28:27 +00:00 committed by Richard Sandiford
parent 036620db8a
commit 4edd6298d8
12 changed files with 32 additions and 26 deletions

View File

@ -1,3 +1,20 @@
2017-09-12 Richard Sandiford <richard.sandiford@linaro.org>
* config/aarch64/aarch64.c (aarch64_hard_regno_mode_ok): Use
end_hard_regno instead of hard_regno_nregs.
* config/s390/s390.c (s390_reg_clobbered_rtx): Likewise.
* config/sparc/sparc.h (ASM_DECLARE_REGISTER_GLOBAL): Likewise.
* config/visium/visium.c (visium_hard_regno_mode_ok): Likewise.
* ira-color.c (improve_allocation): Likewise.
* lra-assigns.c (find_hard_regno_for_1): Likewise.
* lra-lives.c (mark_regno_live): Likewise.
(mark_regno_dead): Likewise.
* lra-remat.c (operand_to_remat): Likewise.
* lra.c (collect_non_operand_hard_regs): Likewise.
* postreload.c (reload_combine_note_store): Likewise.
(move2add_valid_value_p): Likewise.
* reload.c (regno_clobbered_p): Likewise.
2017-09-12 Richard Sandiford <richard.sandiford@linaro.org>
* config/frv/frv.c (FOR_EACH_REGNO): Use END_REGNO instead of

View File

@ -1106,8 +1106,7 @@ aarch64_hard_regno_mode_ok (unsigned regno, machine_mode mode)
if (FP_REGNUM_P (regno))
{
if (aarch64_vect_struct_mode_p (mode))
return
(regno + aarch64_hard_regno_nregs (regno, mode) - 1) <= V31_REGNUM;
return end_hard_regno (mode, regno) - 1 <= V31_REGNUM;
else
return true;
}

View File

@ -9630,7 +9630,7 @@ s390_reg_clobbered_rtx (rtx setreg, const_rtx set_insn ATTRIBUTE_UNUSED, void *d
return;
for (i = regno;
i < regno + HARD_REGNO_NREGS (regno, mode);
i < end_hard_regno (mode, regno);
i++)
regs_ever_clobbered[i] = 1;
}

View File

@ -1248,7 +1248,7 @@ extern GTY(()) char sparc_hard_reg_printed[8];
do { \
if (TARGET_ARCH64) \
{ \
int end = HARD_REGNO_NREGS ((REGNO), DECL_MODE (decl)) + (REGNO); \
int end = end_hard_regno (DECL_MODE (decl), REGNO); \
int reg; \
for (reg = (REGNO); reg < 8 && reg < end; reg++) \
if ((reg & ~1) == 2 || (reg & ~1) == 6) \

View File

@ -857,7 +857,7 @@ static bool
visium_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
{
if (GP_REGISTER_P (regno))
return GP_REGISTER_P (regno + HARD_REGNO_NREGS (regno, mode) - 1);
return GP_REGISTER_P (end_hard_regno (mode, regno) - 1);
if (FP_REGISTER_P (regno))
return mode == SFmode || (mode == SImode && TARGET_FPU_IEEE);

View File

@ -2893,7 +2893,7 @@ improve_allocation (void)
conflict_nregs
= hard_regno_nregs[conflict_hregno][ALLOCNO_MODE (conflict_a)];
for (r = conflict_hregno;
r >= 0 && r + hard_regno_nregs[r][mode] > conflict_hregno;
r >= 0 && (int) end_hard_regno (mode, r) > conflict_hregno;
r--)
if (check_hard_reg_p (a, r,
conflicting_regs, profitable_hard_regs))

View File

@ -578,7 +578,7 @@ find_hard_regno_for_1 (int regno, int *cost, int try_only_hard_regno,
hr++)
SET_HARD_REG_BIT (impossible_start_hard_regs, hr);
for (hr = conflict_hr - 1;
hr >= 0 && hr + hard_regno_nregs[hr][biggest_mode] > conflict_hr;
hr >= 0 && (int) end_hard_regno (biggest_mode, hr) > conflict_hr;
hr--)
SET_HARD_REG_BIT (impossible_start_hard_regs, hr);
}

View File

@ -314,9 +314,7 @@ mark_regno_live (int regno, machine_mode mode, int point)
if (regno < FIRST_PSEUDO_REGISTER)
{
for (last = regno + hard_regno_nregs[regno][mode];
regno < last;
regno++)
for (last = end_hard_regno (mode, regno); regno < last; regno++)
make_hard_regno_born (regno, false);
}
else
@ -343,9 +341,7 @@ mark_regno_dead (int regno, machine_mode mode, int point)
if (regno < FIRST_PSEUDO_REGISTER)
{
for (last = regno + hard_regno_nregs[regno][mode];
regno < last;
regno++)
for (last = end_hard_regno (mode, regno); regno < last; regno++)
make_hard_regno_dead (regno);
}
else

View File

@ -367,8 +367,7 @@ operand_to_remat (rtx_insn *insn)
if (reg2->type == OP_OUT
&& reg->regno <= reg2->regno
&& (reg2->regno
< (reg->regno
+ hard_regno_nregs[reg->regno][reg->biggest_mode])))
< (int) end_hard_regno (reg->biggest_mode, reg->regno)))
return -1;
}
/* Check hard coded insn registers. */

View File

@ -846,9 +846,7 @@ collect_non_operand_hard_regs (rtx *x, lra_insn_recog_data_t data,
return list;
/* Process all regs even unallocatable ones as we need info
about all regs for rematerialization pass. */
for (last = regno + hard_regno_nregs[regno][mode];
regno < last;
regno++)
for (last = end_hard_regno (mode, regno); regno < last; regno++)
{
for (curr = list; curr != NULL; curr = curr->next)
if (curr->regno == regno && curr->subreg_p == subreg_p

View File

@ -1453,7 +1453,7 @@ reload_combine_note_store (rtx dst, const_rtx set, void *data ATTRIBUTE_UNUSED)
if (GET_CODE (SET_DEST (set)) == ZERO_EXTRACT
|| GET_CODE (SET_DEST (set)) == STRICT_LOW_PART)
{
for (i = hard_regno_nregs[regno][mode] - 1 + regno; i >= regno; i--)
for (i = end_hard_regno (mode, regno) - 1; i >= regno; i--)
{
reg_state[i].use_index = -1;
reg_state[i].store_ruid = reload_combine_ruid;
@ -1462,7 +1462,7 @@ reload_combine_note_store (rtx dst, const_rtx set, void *data ATTRIBUTE_UNUSED)
}
else
{
for (i = hard_regno_nregs[regno][mode] - 1 + regno; i >= regno; i--)
for (i = end_hard_regno (mode, regno) - 1; i >= regno; i--)
{
reg_state[i].store_ruid = reload_combine_ruid;
if (GET_CODE (set) == SET)
@ -1717,8 +1717,8 @@ move2add_valid_value_p (int regno, scalar_int_mode mode)
return false;
}
for (int i = hard_regno_nregs[regno][mode] - 1; i > 0; i--)
if (reg_mode[regno + i] != BLKmode)
for (int i = end_hard_regno (mode, regno) - 1; i > regno; i--)
if (reg_mode[i] != BLKmode)
return false;
return true;
}

View File

@ -7180,13 +7180,10 @@ int
regno_clobbered_p (unsigned int regno, rtx_insn *insn, machine_mode mode,
int sets)
{
unsigned int nregs, endregno;
/* regno must be a hard register. */
gcc_assert (regno < FIRST_PSEUDO_REGISTER);
nregs = hard_regno_nregs[regno][mode];
endregno = regno + nregs;
unsigned int endregno = end_hard_regno (mode, regno);
if ((GET_CODE (PATTERN (insn)) == CLOBBER
|| (sets == 1 && GET_CODE (PATTERN (insn)) == SET))