]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR103074] LRA: Check new conflicts when splitting hard reg live range.
authorVladimir N. Makarov <vmakarov@redhat.com>
Thu, 10 Mar 2022 21:16:00 +0000 (16:16 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Thu, 10 Mar 2022 21:16:49 +0000 (16:16 -0500)
Splitting hard register live range can create (artificial)
conflict of the hard register with another pseudo because of simplified
conflict calculation in LRA.  We should check such conflict on the next
assignment sub-pass and spill and reassign the pseudo if necessary.
The patch implements this.

gcc/ChangeLog:

PR target/103074
* lra-constraints.cc (split_reg): Set up
check_and_force_assignment_correctness_p when splitting hard
register live range.

gcc/testsuite/ChangeLog:

PR target/103074
* gcc.target/i386/pr103074.c: New.

gcc/lra-constraints.cc
gcc/testsuite/gcc.target/i386/pr103074.c [new file with mode: 0644]

index 080b44ad87ab0fc2814829823be5148d0da873eb..d92ab76908c8e07219ae9efd55eafbe76430e3f7 100644 (file)
@@ -5994,12 +5994,17 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn,
                         before_p ? NULL : save,
                         call_save_p
                         ?  "Add save<-reg" : "Add split<-reg");
-  if (nregs > 1)
+  if (nregs > 1 || original_regno < FIRST_PSEUDO_REGISTER)
     /* If we are trying to split multi-register.  We should check
        conflicts on the next assignment sub-pass.  IRA can allocate on
        sub-register levels, LRA do this on pseudos level right now and
        this discrepancy may create allocation conflicts after
-       splitting.  */
+       splitting.
+
+       If we are trying to split hard register we should also check conflicts
+       as such splitting can create artificial conflict of the hard register
+       with another pseudo because of simplified conflict calculation in
+       LRA.  */
     check_and_force_assignment_correctness_p = true;
   if (lra_dump_file != NULL)
     fprintf (lra_dump_file,
diff --git a/gcc/testsuite/gcc.target/i386/pr103074.c b/gcc/testsuite/gcc.target/i386/pr103074.c
new file mode 100644 (file)
index 0000000..276ad82
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-march=bonnell -Os -fPIC -fschedule-insns -w" } */
+
+void
+serialize_collection (char *ptr, int a, int need_owner)
+{
+  if (need_owner)
+    __builtin_sprintf(ptr, "%d:%d", 0, a);
+  else
+    {
+      static char buff[32];
+
+      __builtin_sprintf(buff, "%d:%d", a >> 32, a);
+      __builtin_sprintf(ptr, "%d:%d:\"%s\"", 0, 0, buff);
+    }
+}