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]
Other format: [Raw text]

[PATCH] loop unrolling reg notes (was: Performance regression)


	The bug exposed by the earlier ZERO_EXTEND patch appears to be
that CSE assumes REG_EQUAL notes always are valid after the insn has
executed, which may not be the case if the pseudo which is the destination
of the SET in the instruction is replicated by loop unrolling.  When the
loop is unrolled, the pseudo may be set repeatedly, but CSE does not
perform a flow analysis to ensure that the earlier SET still corresponds
to the current value equivalent to the REG_EQUAL note.

David


	* unroll.c (copy_loop_body): Remove REG_EQUAL note attached to
	copied instruction if the note is not loop invariant.

Index: unroll.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/unroll.c,v
retrieving revision 1.179
diff -c -p -r1.179 unroll.c
*** unroll.c	30 Sep 2002 19:35:17 -0000	1.179
--- unroll.c	4 Oct 2002 20:13:57 -0000
*************** copy_loop_body (loop, copy_start, copy_e
*** 2033,2038 ****
--- 2033,2045 ----
  	  REG_NOTES (copy) = initial_reg_note_copy (REG_NOTES (insn), map);
  	  INSN_SCOPE (copy) = INSN_SCOPE (insn);
  
+ 	  /* If there is a REG_EQUAL note present whose value
+ 	     is not loop invariant, then delete it, since it
+ 	     may cause problems with later optimization passes.  */
+ 	  if ((tem = find_reg_note (copy, REG_EQUAL, NULL_RTX))
+ 	      && !loop_invariant_p (loop, XEXP (tem, 0)))
+ 	    remove_note (copy, tem);
+ 
  #ifdef HAVE_cc0
  	  /* If this insn is setting CC0, it may need to look at
  	     the insn that uses CC0 to see what type of insn it is.


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