And here's a followup to clean up the mess I made in
lra_update_fp2sp_elimination, without any functional changes.


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.

Regstrapped on x86_64-linux-gnu, bootstrapped on arm-linux-gnueabihf
(arm and thumb modes), also tested with gcc-14 on arm-vx7r2 and
arm-linux-gnueabihf.  Ok to install?


for  gcc/ChangeLog

        PR rtl-optimization/120424
        * lra-elimination.cc (lra_update_fp2sp_elimination): Reorder
        and regroup related statements.
---
 gcc/lra-eliminations.cc |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
index 0a702a43a5a17..5713a96805233 100644
--- a/gcc/lra-eliminations.cc
+++ b/gcc/lra-eliminations.cc
@@ -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;
 }
 


-- 
Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!

Reply via email to