[PR124572, LRA]: Deal with generation of reload insns during elimination

It was assumed that elimination in LRA does not generate new reload
insns.  In the testcase the elimination of SFP subreg generates reload
insn of the subreg and this insn is added at end of RTL code.  The insn
is also skipped for necessary processing.  This results in ICE.  The patch
checks creation of reloads insn during elimination, insert them in the right
place, and add them for later processing.

gcc/ChangeLog:

	PR rtl-optimization/124572
	* lra-eliminations.cc (lra_eliminate): Push new reload insns for
	eliminations in insns.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/124572
	* gcc.target/aarch64/pr124572.c: New.
This commit is contained in:
Vladimir N. Makarov
2026-03-24 09:05:59 -04:00
parent 5cd3889135
commit 4eef89cc39
2 changed files with 23 additions and 2 deletions

View File

@@ -1544,8 +1544,19 @@ lra_eliminate (bool final_p, bool first_p)
EXECUTE_IF_SET_IN_BITMAP (&insns_with_changed_offsets, 0, uid, bi)
/* A dead insn can be deleted in process_insn_for_elimination. */
if (lra_insn_recog_data[uid] != NULL)
process_insn_for_elimination (lra_insn_recog_data[uid]->insn,
final_p, first_p);
{
rtx_insn *insn = lra_insn_recog_data[uid]->insn;
start_sequence ();
process_insn_for_elimination (insn, final_p, first_p);
rtx_insn *first = get_insns ();
end_sequence ();
if (first != NULL)
{
lra_assert (!final_p);
lra_process_new_insns (insn, first, NULL,
"Inserting elimination insn", true);
}
}
bitmap_clear (&insns_with_changed_offsets);
lra_eliminate_done:

View File

@@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-O2" } */
int e() {
char f;
long tt = (long)&f;
tt+=1;
int g = tt;
return g + 3;
}