From: Vladimir N. Makarov Date: Mon, 25 Nov 2024 21:09:00 +0000 (-0500) Subject: [PR117105][LRA]: Use unique value reload pseudo for early clobber operand X-Git-Tag: basepoints/gcc-16~3895 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b09e2c67ef593db171b0755b46378964421782b;p=thirdparty%2Fgcc.git [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. --- diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 61bbb930b7f4..052e5f71f1e1 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -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)) diff --git a/gcc/testsuite/gcc.target/i386/pr117105.c b/gcc/testsuite/gcc.target/i386/pr117105.c new file mode 100644 index 000000000000..252bb138c9c7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr117105.c @@ -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; +}