aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir N. Makarov <vmakarov@redhat.com>2024-11-25 16:09:00 -0500
committerVladimir N. Makarov <vmakarov@redhat.com>2024-11-25 16:11:46 -0500
commit4b09e2c67ef593db171b0755b46378964421782b (patch)
tree44371f12e1eb3012f19415595b802783e0ad0f4d
parent551fd4d5c98859522dd21db6fbb39fceac3936b2 (diff)
downloadgcc-4b09e2c67ef593db171b0755b46378964421782b.zip
gcc-4b09e2c67ef593db171b0755b46378964421782b.tar.gz
gcc-4b09e2c67ef593db171b0755b46378964421782b.tar.bz2
[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.
-rw-r--r--gcc/lra-constraints.cc3
-rw-r--r--gcc/testsuite/gcc.target/i386/pr117105.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc
index 61bbb93..052e5f7 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 0000000..252bb13
--- /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;
+}