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]

PATCH: PA PIC symbolic memory fix PART 2


The enclosed patch changes update_equiv_regs to not add REG_EQUIV notes
to MEMs that are unstable, that is a MEM that could be different at a
different point in the program.

The PA uses an unstable MEM for long `PIC' references.  The MEM for short
`pic' references uses the pic_offset_table_rtx.  Because the PA port defines
PIC_OFFSET_TABLE_REG_CALL_CLOBBERED, short pic references are currently
treated as unstable.  However, I believe that they could now be treated
as stable because the problem that arose when the pic_offset_table_rtx
was previously treated as stable has been fixed.  The problem was the
insn to restore the pic_offset_table_rtx was being deleted after function
calls.

I can hear Jeff saying that the REG_EQUIV notes are valid and removing
them is just fixing a symptom of the problem!  However, even if they
are valid, no registers are saved by substituting the MEMs for long
PIC references because the register used to construct the LO_SUM must
be kept alive or saved in the frame.  It is better to keep the register
with the address result alive, and let the intermediate temporary register
die.

Trying to update reload to allow it to substitute unstable MEMs appears
to me to be very challenging.  The reason it is difficult is the register
used in the MEM may die and possibly get reused between the point of
death and where the substitution occurs.  The flow analysis and the
removal of register conflicts appear very involved.  This would likely
further reduce compiler performance.

This patch is simple and should have limited side effects.  It allows
me to do a full bootstrap check in PIC mode, something that has not
been possible previously for hppa1.1-hp-hpux10.20.

Please review?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-02-17  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* local-alloc.c (update_equiv_regs): Only add REG_EQUIV notes to MEMs
	that are not unstable.

--- local-alloc.c.orig	Thu Feb  1 20:03:47 2001
+++ local-alloc.c	Sat Feb 17 15:27:25 2001
@@ -893,6 +893,7 @@
 	  && REG_N_SETS (regno) == 1
 	  && reg_equiv[regno].init_insns != 0
 	  && reg_equiv[regno].init_insns != const0_rtx
+	  && ! rtx_unstable_p (dest)
 	  && ! find_reg_note (XEXP (reg_equiv[regno].init_insns, 0),
 			      REG_EQUIV, NULL_RTX)
 	  && ! contains_replace_regs (XEXP (dest, 0)))
@@ -956,9 +957,9 @@
       reg_equiv[regno].init_insns
 	= gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv[regno].init_insns);
 
-      /* If this register is known to be equal to a constant, record that
-	 it is always equivalent to the constant.  */
-      if (note && ! rtx_varies_p (XEXP (note, 0), 0))
+      /* If this register is known to always be equal to a constant, record
+	 that it is always equivalent to the constant.  */
+      if (note && ! rtx_unstable_p (XEXP (note, 0)))
 	PUT_MODE (note, (enum machine_mode) REG_EQUIV);
 
       /* If this insn introduces a "constant" register, decrease the priority
@@ -980,6 +981,7 @@
 
       if (note == 0 && REG_BASIC_BLOCK (regno) >= 0
 	  && GET_CODE (SET_SRC (set)) == MEM
+	  && ! rtx_unstable_p (SET_SRC (set))
 	  && validate_equiv_mem (insn, dest, SET_SRC (set)))
 	REG_NOTES (insn) = note = gen_rtx_EXPR_LIST (REG_EQUIV, SET_SRC (set),
 						     REG_NOTES (insn));


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