[PR117105][LRA]: Use unique value reload pseudo for early clobber operand

LRA did not generate insn satisfying insn constraints on the PR
test.  The reason for this is that LRA assigned the same hard reg for
two conflicting reload pseudos.  The two insn reload pseudos are
originated from the same pseudo and LRA tried to optimize as it
assigned the same value for the reload pseudos.  It is an LRA
optimization to minimize reload insns.  The two reload pseudos
conflict as one of them is an early clobber insn operands.  The patch
solves this problem by assigning unique value if the operand is early
clobber one.

gcc/ChangeLog:

	PR target/117105
	* lra-constraints.cc (get_reload_reg): Create unique value reload
	pseudos for early clobbered operands.

gcc/testsuite/ChangeLog:

	PR target/117105
	* gcc.target/i386/pr117105.c: New test.
This commit is contained in:
Vladimir N. Makarov 2024-11-25 16:09:00 -05:00
parent 551fd4d5c9
commit 4b09e2c67e
2 changed files with 17 additions and 1 deletions

View File

@ -663,7 +663,6 @@ get_reload_reg (enum op_type type, machine_mode mode, rtx original,
{
int i, regno;
enum reg_class new_class;
bool unique_p = false;
if (type == OP_OUT)
{
@ -702,6 +701,8 @@ get_reload_reg (enum op_type type, machine_mode mode, rtx original,
exclude_start_hard_regs, title);
return true;
}
bool unique_p = early_clobber_p;
/* Prevent reuse value of expression with side effects,
e.g. volatile memory. */
if (! side_effects_p (original))

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-O3 -fno-code-hoisting -fno-tree-fre -fno-tree-dominator-opts -fno-tree-pre -fno-tree-sra" } */
int a;
struct b {
char c;
char d;
};
int main() {
struct b e;
int f;
while (a)
if (f == e.d)
f = e.c = e.d & 1 >> e.d;
return 0;
}