jump_optimize enhancement

Joern Rennecke amylaar@cygnus.co.uk
Wed Feb 10 11:07:00 GMT 1999


jump_optimize drops all REG_NOTES when it moves an insn.  At least a
REG_EQUAL note for a function invariant can be safely kept.

	* emit-rtl.c (emit_insn_after_with_line_notes): return the insn.
	* rtl.h (emit_insn_after_with_line_notes): Update prototype.
	* jump.c (jump_optimize): When moving an insn, keep REG_EQUAL
	note for function invariant.

Index: rtl.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/rtl.h,v
retrieving revision 1.105.2.1
diff -p -r1.105.2.1 rtl.h
*** rtl.h	1999/01/28 00:26:15	1.105.2.1
--- rtl.h	1999/02/10 19:03:03
*************** extern void add_insn				PROTO ((rtx));
*** 1353,1359 ****
  extern void add_insn_before			PROTO ((rtx, rtx));
  extern void add_insn_after			PROTO ((rtx, rtx));
  extern void reorder_insns_with_line_notes	PROTO ((rtx, rtx, rtx));
! extern void emit_insn_after_with_line_notes	PROTO ((rtx, rtx, rtx));
  extern enum rtx_code classify_insn		PROTO ((rtx));
  extern void init_virtual_regs                   PROTO ((void));
  extern rtx emit					PROTO ((rtx));
--- 1353,1359 ----
  extern void add_insn_before			PROTO ((rtx, rtx));
  extern void add_insn_after			PROTO ((rtx, rtx));
  extern void reorder_insns_with_line_notes	PROTO ((rtx, rtx, rtx));
! extern rtx emit_insn_after_with_line_notes	PROTO ((rtx, rtx, rtx));
  extern enum rtx_code classify_insn		PROTO ((rtx));
  extern void init_virtual_regs                   PROTO ((void));
  extern rtx emit					PROTO ((rtx));
Index: emit-rtl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/emit-rtl.c,v
retrieving revision 1.123
diff -p -r1.123 emit-rtl.c
*** emit-rtl.c	1999/01/21 19:46:39	1.123
--- emit-rtl.c	1999/02/10 19:03:04
*************** emit_insn_after (pattern, after)
*** 2711,2717 ****
  /* Similar to emit_insn_after, except that line notes are to be inserted so
     as to act as if this insn were at FROM.  */
  
! void
  emit_insn_after_with_line_notes (pattern, after, from)
       rtx pattern, after, from;
  {
--- 2711,2717 ----
  /* Similar to emit_insn_after, except that line notes are to be inserted so
     as to act as if this insn were at FROM.  */
  
! rtx
  emit_insn_after_with_line_notes (pattern, after, from)
       rtx pattern, after, from;
  {
*************** emit_insn_after_with_line_notes (pattern
*** 2728,2733 ****
--- 2728,2734 ----
      emit_line_note_after (NOTE_SOURCE_FILE (after_line),
  			  NOTE_LINE_NUMBER (after_line),
  			  insn);
+   return insn;
  }
  
  /* Make an insn of code JUMP_INSN with body PATTERN
Index: jump.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/jump.c,v
retrieving revision 1.141
diff -p -r1.141 jump.c
*** jump.c	1999/01/20 05:32:42	1.141
--- jump.c	1999/02/10 19:03:05
*************** jump_optimize (f, cross_jump, noop_moves
*** 576,582 ****
  					   PREV_INSN (temp2),
  					   NEXT_INSN (temp2)))
  		{
! 		  emit_insn_after_with_line_notes (PATTERN (temp2), p, temp2);
  		  delete_insn (temp2);
  
  		  /* Set NEXT to an insn that we know won't go away.  */
--- 576,590 ----
  					   PREV_INSN (temp2),
  					   NEXT_INSN (temp2)))
  		{
! 		  rtx note = find_reg_note (temp2, REG_EQUAL, NULL_RTX);
! 		  rtx temp3 = emit_insn_after_with_line_notes (PATTERN (temp2),
! 							       p, temp2);
! 
! 		  if (note && function_invariant_p (XEXP (note, 0)))
! 		    {
! 		      XEXP (note, 1) = NULL_RTX;
! 		      REG_NOTES (temp3) = note;
! 		    }
  		  delete_insn (temp2);
  
  		  /* Set NEXT to an insn that we know won't go away.  */


More information about the Gcc-patches mailing list