[gcc(refs/users/aoliva/heads/testme)] [lra] take scratch as implicit unused output reloads [PR55212]
Alexandre Oliva
aoliva@gcc.gnu.org
Wed Dec 17 02:13:16 GMT 2025
https://gcc.gnu.org/g:15f8ce096527c8ac55bb4a9c2954d2db80aa4efc
commit 15f8ce096527c8ac55bb4a9c2954d2db80aa4efc
Author: Alexandre Oliva <oliva@gnu.org>
Date: Mon Aug 5 14:16:37 2024 -0300
[lra] take scratch as implicit unused output reloads [PR55212]
When trying to convert the SH port to use LRA, the first issue I hit
was the need for dealing with former scratch registers at places we
didn't need to on other ports, treating them like unused output
reloads instead of rejecting them.
for gcc/ChangeLog
PR target/55212
* lra-constraints.cc (match_reload): Treat former scratch
regs as implicit unused output reloads.
(process_alt_operands): Likewise.
(curr_insn_transform): Likewise.
Diff:
---
gcc/lra-constraints.cc | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 66a300bf268b..910f3fba8f47 100644
--- a/gcc/lra-constraints.cc
+++ b/gcc/lra-constraints.cc
@@ -1243,7 +1243,9 @@ match_reload (signed char out, signed char *ins, signed char *outs,
return;
/* See a comment for the input operand above. */
narrow_reload_pseudo_class (out_rtx, goal_class);
- if (find_reg_note (curr_insn, REG_UNUSED, out_rtx) == NULL_RTX)
+ if (find_reg_note (curr_insn, REG_UNUSED, out_rtx) == NULL_RTX
+ && !ira_former_scratch_p (REGNO (SUBREG_P (out_rtx)
+ ? SUBREG_REG (out_rtx) : out_rtx)))
{
reg = SUBREG_P (out_rtx) ? SUBREG_REG (out_rtx) : out_rtx;
start_sequence ();
@@ -3002,7 +3004,8 @@ process_alt_operands (int only_alternative)
objects with a REG_UNUSED note. */
if ((curr_static_id->operand[nop].type != OP_IN
&& no_output_reloads_p
- && ! find_reg_note (curr_insn, REG_UNUSED, op))
+ && ! find_reg_note (curr_insn, REG_UNUSED, op)
+ && ! scratch_p)
|| (curr_static_id->operand[nop].type != OP_OUT
&& no_input_reloads_p && ! const_to_mem)
|| (this_alternative_matches >= 0
@@ -3012,7 +3015,8 @@ process_alt_operands (int only_alternative)
[this_alternative_matches].type != OP_IN)
&& ! find_reg_note (curr_insn, REG_UNUSED,
no_subreg_reg_operand
- [this_alternative_matches])))))
+ [this_alternative_matches])
+ && ! scratch_p))))
{
if (lra_dump_file != NULL)
fprintf
@@ -4856,7 +4860,8 @@ curr_insn_transform (bool check_only_p)
if (type != OP_IN
&& find_reg_note (curr_insn, REG_UNUSED, old) == NULL_RTX
/* OLD can be an equivalent constant here. */
- && !CONSTANT_P (old))
+ && !CONSTANT_P (old)
+ && !ira_former_scratch_p (REGNO (old)))
{
start_sequence ();
lra_emit_move (type == OP_INOUT ? copy_rtx (old) : old, new_reg);
More information about the Gcc-cvs
mailing list