This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Is http://www.cygnus.com/ml/egcs-bugs/1998-Jul/0147.html fixed


> 
> >>>>> H J Lu <hjl@lucon.org> writes:
> 
> > Is http://www.cygnus.com/ml/egcs-bugs/1998-Jul/0147.html fixed?
> 
> What, you can't be bothered to check, so you send mail to zing asking
> someone else to check for you?  For a bug report against 1.0.3?
> 
> To answer your question, no, it's still broken.  It dies in reg-stack.
> 
> Jason
> 

It dies on me too. I just want to make sure I didn't do anything wrong.
Here is a patch. The problem is the register on the stack reg-stack.c
is virtual. That is why we have get_hard_regnum () to get the hard
register number from the virtual register.


-- 
H.J. Lu (hjl@gnu.org)
---
http://www.cygnus.com/ml/egcs-bugs/1998-Jul/0147.html

Tue Jul  7 21:08:22 1998  H.J. Lu  (hjl@gnu.org)

	* reg-stack.c (straighten_stack): Handle the virtual register
	stack.

--- ../../../import/egcs/gcc/reg-stack.c	Mon Apr 20 08:23:00 1998
+++ ./reg-stack.c	Tue Jul  7 21:05:56 1998
@@ -297,7 +297,7 @@ mark_regs_pat (pat, set)
      SET_HARD_REG_BIT (*set, regno);
 }
 
-/* Reorganise the stack into ascending numbers,
+/* Reorganise the virtual register stack into ascending numbers,
    after this insn.  */
 
 static void
@@ -305,15 +305,27 @@ straighten_stack (insn, regstack)
      rtx insn;
      stack regstack;
 {
-  struct stack_def temp_stack;
-  int top;
+  if (regstack->top > 0)
+    {
+      struct stack_def temp_stack;
+      int top;
+      int first_start_reg;
+
+#if defined(__GNUC__) && __GNUC__ >= 2 && defined (__OPTIMIZE__)
+      first_start_reg = ffs (regstack->reg_set) - 1;
+#else
+      first_start_reg = 0;
+      for (top = regstack->reg_set; (top & 1) == 0; top >>= 1)
+	first_start_reg++;
+#endif
 
-  temp_stack.reg_set = regstack->reg_set;
+      temp_stack.reg_set = regstack->reg_set;
 
-  for (top = temp_stack.top = regstack->top; top >= 0; top--)
-     temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top;
+      for (top = temp_stack.top = regstack->top; top >= 0; top--)
+	temp_stack.reg[top] = first_start_reg + temp_stack.top - top;
   
-  change_stack (insn, regstack, &temp_stack, emit_insn_after);
+      change_stack (insn, regstack, &temp_stack, emit_insn_after);
+    }
 }
 
 /* Return non-zero if any stack register is mentioned somewhere within PAT.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]