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]

Avoid messing up loop notes 3 take 2


Hi,
it looks cleaner to set an global variable, as we do for cse_not_expected.

The patch avoids removing of loop pre-headers to avoid loop.c confussion.

Bootstrapped/regtested i686 with the next patch.

Honza

Fri Jul 27 18:43:06 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* expr.c (loop_not_expected): New global variable.
	* rtl.h (loop_not_expected): Declare.
	* flow.c (try_forward_edges): Avoid removing of loop pre-headers
	before loop.
	* toplev.c (rest_of_compilation): Set loop_not_expected.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.340
diff -c -3 -p -r1.340 expr.c
*** expr.c	2001/07/20 20:07:58	1.340
--- expr.c	2001/07/27 16:41:39
*************** int (*lang_safe_from_p) PARAMS ((rtx, tr
*** 86,91 ****
--- 86,94 ----
     the same indirect address eventually.  */
  int cse_not_expected;
  
+ /* When nonzero, it is possible to destroy pre-headers of syntactic loops.  */
+ int loop_not_expected;
+ 
  /* Don't check memory usage, since code is being emitted to check a memory
     usage.  Used when current_function_check_memory_usage is true, to avoid
     infinite recursion.  */
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.446
diff -c -3 -p -r1.446 flow.c
*** flow.c	2001/07/27 15:55:41	1.446
--- flow.c	2001/07/27 16:41:44
*************** try_forward_edges (b)
*** 3173,3178 ****
--- 3173,3202 ----
  	  /* Bypass trivial infinite loops.  */
  	  if (target == target->succ->dest)
  	    counter = n_basic_blocks;
+ 	  /* Avoid killing of loop pre-headers, as it is the place loop
+ 	     optimizer wants to hoist code to.
+ 	 
+ 	     For fallthru forwarders, the LOOP_BEG note must appear between
+ 	     the header of block and CODE_LABEL of the loop, for non forwarders
+ 	     it must appear before the JUMP_INSN.
+ 	   */
+ 	  if (!loop_not_expected)
+ 	    {
+ 	      rtx insn = (target->succ->flags & EDGE_FALLTHRU 
+ 		          ? target->head : prev_nonnote_insn (target->end));
+ 
+ 	      if (GET_CODE (insn) != NOTE)
+ 		insn = NEXT_INSN (insn);
+ 
+ 	      for (;insn && GET_CODE (insn) != CODE_LABEL && !INSN_P (insn);
+ 		   insn = NEXT_INSN (insn))
+ 		if (GET_CODE (insn) == NOTE
+ 		    && NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
+ 		  break;
+ 
+ 	      if (GET_CODE (insn) == NOTE)
+ 		break;
+ 	    }
  	  target = target->succ->dest, counter++;
  	}
  
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.280
diff -c -3 -p -r1.280 rtl.h
*** rtl.h	2001/07/26 23:47:15	1.280
--- rtl.h	2001/07/27 16:41:47
*************** extern int reload_in_progress;
*** 1666,1671 ****
--- 1666,1674 ----
     the same indirect address eventually.  */
  extern int cse_not_expected;
  
+ /* When nonzero, it is possible to destroy pre-headers of syntactic loops.  */
+ extern int loop_not_expected;
+ 
  /* Set to nonzero before life analysis to indicate that it is unsafe to
     generate any new pseudo registers.  */
  extern int no_new_pseudos;
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.500
diff -c -3 -p -r1.500 toplev.c
*** toplev.c	2001/07/26 20:36:01	1.500
--- toplev.c	2001/07/27 16:41:49
*************** rest_of_compilation (decl)
*** 2616,2621 ****
--- 2616,2622 ----
    /* When processing delayed functions, prepare_function_start() won't
       have been run to re-initialize it.  */
    cse_not_expected = ! optimize;
+   loop_not_expected = ! optimize;
  
    /* First, make sure that NOTE_BLOCK is set correctly for each
       NOTE_INSN_BLOCK_BEG/NOTE_INSN_BLOCK_END note.  */
*************** rest_of_compilation (decl)
*** 3122,3127 ****
--- 3123,3130 ----
        ggc_collect ();
      }
  
+   loop_not_expected = 1;
+ 
    if (optimize > 0)
      {
        timevar_push (TV_CSE2);


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