]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[lra] reorder operations in lra_update_fp2sp_elimination [PR120424]
authorAlexandre Oliva <oliva@adacore.com>
Fri, 27 Jun 2025 00:01:26 +0000 (21:01 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 27 Jun 2025 00:10:10 +0000 (21:10 -0300)
The various recent additions to lra_update_fp2sp_elimination rendered
it somewhat confusing, with intermixed groups of statements pertaining
to three different major actions: disabling the elimination,
recomputing live ranges, and spilling uses of the frame pointer.
Reorder them for readability.

for  gcc/ChangeLog

PR rtl-optimization/120424
* lra-eliminations.cc (lra_update_fp2sp_elimination): Reorder
and regroup related statements.

gcc/lra-eliminations.cc

index 0a702a43a5a17be8e5522a5683a82f097e35bdf2..5713a96805233f6d720a3caa30e452de6f6038b4 100644 (file)
@@ -1436,13 +1436,13 @@ lra_update_fp2sp_elimination (int *spilled_pseudos)
       setup_can_eliminate (ep, false);
     }
   else
-    ep = NULL;
+    for (ep = reg_eliminate; ep < &reg_eliminate[NUM_ELIMINABLE_REGS]; ep++)
+      if (ep->from == FRAME_POINTER_REGNUM && ep->to == STACK_POINTER_REGNUM)
+       setup_can_eliminate (ep, false);
   if (lra_dump_file != NULL)
     fprintf (lra_dump_file,
             "     Frame pointer can not be eliminated anymore\n");
   frame_pointer_needed = true;
-  CLEAR_HARD_REG_SET (set);
-  add_to_hard_reg_set (&set, Pmode, HARD_FRAME_POINTER_REGNUM);
   /* If !lra_reg_spill_p, we likely have incomplete range information
      for pseudos assigned to the frame pointer that will have to be
      spilled, and so we may end up incorrectly sharing them unless we
@@ -1451,11 +1451,9 @@ lra_update_fp2sp_elimination (int *spilled_pseudos)
     /* If lives ranges changed, update the aggregate live ranges in
        slots as well before spilling any further pseudos.  */
     lra_recompute_slots_live_ranges ();
+  CLEAR_HARD_REG_SET (set);
+  add_to_hard_reg_set (&set, Pmode, HARD_FRAME_POINTER_REGNUM);
   n = spill_pseudos (set, spilled_pseudos);
-  if (!ep)
-    for (ep = reg_eliminate; ep < &reg_eliminate[NUM_ELIMINABLE_REGS]; ep++)
-      if (ep->from == FRAME_POINTER_REGNUM && ep->to == STACK_POINTER_REGNUM)
-       setup_can_eliminate (ep, false);
   return n;
 }