Improvement for update_equiv_regs

Joern Rennecke amylaar@cygnus.co.uk
Tue Feb 9 08:20:00 GMT 1999


> Seems to me we should try to get those notes attached to the insns earlier
> in the compiler rather than later.
> 
> Is there some reason not to do that?

That's fine, too, but it requires a lot more patches.  Just running two
testcases I found two different pieces of code that need patching:

Tue Feb  9 16:17:59 1999  J"orn Rennecke <amylaar@cygnus.co.uk>

	* cse.c (cse_insn): Add a REG_EQUAL note if SRC is now function
	invariant.
	* combine.c (try_combine):  Add a REG_EQUAL note if SET_SRC (newi2pat)
	is function invariant.

Index: cse.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cse.c,v
retrieving revision 1.164
diff -p -r1.164 cse.c
*** cse.c	1999/01/20 17:50:19	1.164
--- cse.c	1999/02/09 16:16:11
*************** cse_insn (insn, libcall_insn)
*** 7204,7209 ****
--- 7204,7228 ----
  	    }
  	}
  
+       /* Likewise if the new src is a function invariant.  */
+       else if (n_sets == 1 && GET_CODE (dest) == REG
+ 	  && function_invariant_p (src))
+ 	{
+ 	  rtx note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
+ 
+ 	  /* If there alerady was a REG_EQUAL note, don't replace its
+ 	     value if it is already a function invariant.  */
+ 	     
+ 	  if (note)
+ 	    {
+ 	      if (! function_invariant_p (XEXP (note, 0)))
+ 		XEXP (note, 0) = src;
+ 	    }
+ 	  else
+ 	    REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL,
+ 						  src, REG_NOTES (insn));
+ 	}
+ 
        /* Now deal with the destination.  */
        do_not_record = 0;
        sets[i].inner_dest_loc = &SET_DEST (sets[0].rtl);
Index: combine.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/combine.c,v
retrieving revision 1.193
diff -p -r1.193 combine.c
*** combine.c	1999/01/20 17:50:18	1.193
--- combine.c	1999/02/09 16:16:15
*************** try_combine (i3, i2, i1)
*** 2630,2636 ****
  
      note_stores (newpat, set_nonzero_bits_and_sign_copies);
      if (newi2pat)
!       note_stores (newi2pat, set_nonzero_bits_and_sign_copies);
  
      /* If I3 is now an unconditional jump, ensure that it has a 
         BARRIER following it since it may have initially been a
--- 2630,2655 ----
  
      note_stores (newpat, set_nonzero_bits_and_sign_copies);
      if (newi2pat)
!       {
! 	note_stores (newi2pat, set_nonzero_bits_and_sign_copies);
! 	if (function_invariant_p (SET_SRC (newi2pat)))
! 	  {
! 	    rtx note = find_reg_note (i2, REG_EQUAL, NULL_RTX);
! 
! 	    /* If there alerady was a REG_EQUAL note, don't replace its
! 	       value if it is already a function invariant.  */
! 
! 	    if (note)
! 	      {
! 		if (! function_invariant_p (XEXP (note, 0)))
! 		  XEXP (note, 0) = SET_SRC (newi2pat);
! 	      }
! 	    else
! 	      REG_NOTES (i2)
! 		= gen_rtx_EXPR_LIST (REG_EQUAL, SET_SRC (newi2pat),
! 				     REG_NOTES (i2));
! 	  }
!       }
  
      /* If I3 is now an unconditional jump, ensure that it has a 
         BARRIER following it since it may have initially been a


More information about the Gcc-patches mailing list