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

Bernd Schmidt <bernds at gcc dot gnu.org> changed:

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

--- Comment #8 from Bernd Schmidt <bernds at gcc dot gnu.org> ---
I was also playing with this before I noticed Jakub was investigating. As an
experiment, I came up with the following, trying to recognize situations where
picking one alternative would cause an infinite cycle:

Index: lra-constraints.c
===================================================================
--- lra-constraints.c   (revision 245685)
+++ lra-constraints.c   (working copy)
@@ -1899,6 +1899,7 @@ process_alt_operands (int only_alternati
   int reload_nregs, reload_sum;
   bool costly_p;
   enum reg_class cl;
+  bool must_not_reload_op1 = false;

   /* Calculate some data common for all alternatives to speed up the
      function. */
@@ -1932,6 +1933,15 @@ process_alt_operands (int only_alternati
          = regno_reg_rtx[hard_regno[nop]];
     }

+  /* See if we have an insn of the form
+       (set (pseudo) (something)
+     If yes, then we should not try to reload operand 1 into a pseudo,
+     because this would cause an infinite cycle.  */
+  if (curr_insn_set != NULL_RTX
+      && operand_reg[0] != NULL_RTX
+      && hard_regno[0] < 0)
+    must_not_reload_op1 = true;
+
   /* The constraints are made of several alternatives. Each operand's
      constraint looks like foo,bar,... with commas separating the
      alternatives.  The first alternatives for all operands go
@@ -2193,7 +2203,10 @@ process_alt_operands (int only_alternati
                  switch (get_constraint_type (cn))
                    {
                    case CT_REGISTER:
-                     cl = reg_class_for_constraint (cn);
+                     if (nop == 1 && must_not_reload_op1)
+                       cl = NO_REGS;
+                     else
+                       cl = reg_class_for_constraint (cn);
                      if (cl != NO_REGS)
                        goto reg;
                      break;

Sadly, it seems to be ineffective (or at least incomplete), it goes into a
different infinite cycle.

Reply via email to