i386.h CONST_DOUBLE_OK_FOR_LETTER_P

Bernd Schmidt crux@pool.informatik.rwth-aachen.de
Tue Oct 27 01:27:00 GMT 1998


The patch below undoes H.J. Lu's Jul 26 change in i386.h.  It should no longer
be necessary now that PREFERRED_RELOAD_CLASS has been fixed to work with
standard i386 constants.  It is also buggy, because it can cause aborts when
trying to constrain_operands valid insns during reload.

HJ's original test case failed because during reload_as_needed, the variable
current_function_uses_pic_offset_table was set, changing the elimination
offsets.  I suggest we perform some sanity checks that verify that nothing
vital changes during reload_as_needed, and abort if something is wrong.  The
patch below contains such a sanity check, it works by making sure that neither
the initial elimination offsets nor the frame size change during
reload_as_needed.

Bernd

	* reload1.c (verify_initial_offsets): New function.
	(reload): Call it after reload_as_needed.  Also verify that the frame
	size stays constant during reload_as_needed.
	* i386.h (CONST_DOUBLE_OK_FOR_LETTER_P): Undo Jul 26 change.

Index: reload1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/reload1.c,v
retrieving revision 1.85
diff -u -p -r1.85 reload1.c
--- reload1.c	1998/10/22 22:49:04	1.85
+++ reload1.c	1998/10/27 09:10:33
@@ -387,6 +387,7 @@ static int eliminate_regs_in_insn	PROTO(
 static void update_eliminable_offsets	PROTO((void));
 static void mark_not_eliminable		PROTO((rtx, rtx));
 static void set_initial_elim_offsets	PROTO((void));
+static void verify_initial_elim_offsets	PROTO((void));
 static void init_elim_table		PROTO((void));
 static void update_eliminables		PROTO((HARD_REG_SET *));
 static int spill_hard_reg		PROTO((int, int, FILE *, int));
@@ -1150,8 +1151,18 @@ reload (first, global, dumpfile)
      values into or out of the reload registers.  */
 
   if (insns_need_reload != 0 || something_needs_elimination)
-    reload_as_needed (global);
+    {
+      int old_frame_size = get_frame_size ();
+
+      reload_as_needed (global);
 
+      if (old_frame_size != get_frame_size ())
+	abort ();
+
+      if (num_eliminable)
+	verify_initial_elim_offsets ();
+    }
+
   /* If we were able to eliminate the frame pointer, show that it is no
      longer live at the start of any basic block.  If it ls live by
      virtue of being in a pseudo, that pseudo will be marked live
@@ -3743,6 +3754,31 @@ mark_not_eliminable (dest, x)
 	  = reg_eliminate[i].can_eliminate = 0;
 	num_eliminable--;
       }
+}
+
+/* Verify that the initial elimination offsets did not change since the
+   last call to set_initial_elim_offsets.  This is used to catch cases
+   where something illegal happened during reload_as_needed that could
+   cause incorrect code to be generated if we did not check for it.  */
+static void
+verify_initial_elim_offsets ()
+{
+  int t;
+
+#ifdef ELIMINABLE_REGS
+  struct elim_table *ep;
+
+  for (ep = reg_eliminate; ep < &reg_eliminate[NUM_ELIMINABLE_REGS]; ep++)
+    {
+      INITIAL_ELIMINATION_OFFSET (ep->from, ep->to, t);
+      if (t != ep->initial_offset)
+	abort ();
+    }
+#else
+  INITIAL_FRAME_POINTER_OFFSET (t);
+  if (t != reg_eliminate[0].initial_offset)
+    abort ();
+#endif  
 }
 
 /* Reset all offsets on eliminable registers to their initial values.  */
Index: config/i386/i386.h
===================================================================
RCS file: /usr/local/cvs/gcs/gcc/config/i386/i386.h,v
retrieving revision 1.1.1.34
diff -u -p -r1.1.1.34 i386.h
--- i386.h	1998/10/16 13:12:51	1.1.1.34
+++ i386.h	1998/10/25 22:13:06
@@ -891,19 +891,10 @@ enum reg_class
 /* Similar, but for floating constants, and defining letters G and H.
    Here VALUE is the CONST_DOUBLE rtx itself.  We allow constants even if
    TARGET_387 isn't set, because the stack register converter may need to
-   load 0.0 into the function value register.
+   load 0.0 into the function value register.  */
 
-   We disallow these constants when -fomit-frame-pointer and compiling
-   PIC code since reload might need to force the constant to memory.
-   Forcing the constant to memory changes the elimination offsets after
-   the point where they must stay constant.
-
-   However, we must allow them after reload as completed as reg-stack.c
-   will create insns which use these constants.  */
-
 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  \
-  (((reload_completed || !flag_pic || !flag_omit_frame_pointer) && (C) == 'G') \
-   ? standard_80387_constant_p (VALUE) : 0)
+  ((C) == 'G' ? standard_80387_constant_p (VALUE) : 0)
 
 /* Place additional restrictions on the register class to use when it
    is necessary to be able to hold a value of mode MODE in a reload




More information about the Gcc-patches mailing list