https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116374

Michael Matz <matz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at gcc dot gnu.org

--- Comment #1 from Michael Matz <matz at gcc dot gnu.org> ---
Try the below.  m68k has the property that sometimes the initial elimination
offset between %sp and argptr is zero.  But zero is also the initialization
value of the elimation table offsets, and it's _changes_ in those offsets that
trigger various state tracking.  And if the initial "change" is ignored
everything goes downhill from there: in the first_p lra_eliminate() pass
insns_with_changed_offsets will remain empty because "nothing changed", and
hence the initial setup via process_insn_for_elimination()
(with first_p==true) is never carried out.

I guess also -1 is not a very good value (though probably acceptable for all
targets with stack-downwards or wordsize!=1) and should rather be replaced with
some proper "this is the first init" flag.  But ... well.  Hack.

diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
index 5bed259cffe..86741aa5a92 100644
--- a/gcc/lra-eliminations.cc
+++ b/gcc/lra-eliminations.cc
@@ -1283,7 +1283,7 @@ init_elim_table (void)
   for (ep = reg_eliminate, ep1 = reg_eliminate_1;
        ep < &reg_eliminate[NUM_ELIMINABLE_REGS]; ep++, ep1++)
     {
-      ep->offset = ep->previous_offset = 0;
+      ep->offset = ep->previous_offset = -1;
       ep->from = ep1->from;
       ep->to = ep1->to;
       value_p = (targetm.can_eliminate (ep->from, ep->to)

Reply via email to