loop reversing and unrolling (with ChangeLog entry!)

Michael Hayes m.hayes@elec.canterbury.ac.nz
Sat Nov 14 01:29:00 GMT 1998


Ooops, forgot the ChangeLog entries.  Here are the combined patches
again.

Sat Nov 14 22:24:01 1998  Michael Hayes  <m.hayes@elec.canterbury.ac.nz>

	* loop.c (check_dbra_loop): Update JUMP_LABEL field of jump insn
	when loop reversed.

	* unroll.c (precondition_loop_p): Return loop_initial_value
	for initial_value instead of loop_iteration_var.


Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.91
diff -c -3 -p -r1.91 loop.c
*** loop.c	1998/10/15 17:37:58	1.91
--- loop.c	1998/11/14 08:52:01
*************** check_dbra_loop (loop_end, insn_count, l
*** 7085,7100 ****
  	      end_sequence ();
  	      emit_jump_insn_before (tem, loop_end);
  
  	      if (nonneg)
  		{
- 		  for (tem = PREV_INSN (loop_end);
- 		       tem && GET_CODE (tem) != JUMP_INSN;
- 		       tem = PREV_INSN (tem))
- 		    ;
  		  if (tem)
  		    {
- 		      JUMP_LABEL (tem) = XEXP (jump_label, 0);
- 
  		      /* Increment of LABEL_NUSES done above.  */
  		      /* Register is now always nonnegative,
  			 so add REG_NONNEG note to the branch.  */
--- 7085,7102 ----
  	      end_sequence ();
  	      emit_jump_insn_before (tem, loop_end);
  
+ 	      for (tem = PREV_INSN (loop_end);
+ 		   tem && GET_CODE (tem) != JUMP_INSN;
+ 		   tem = PREV_INSN (tem))
+ 		;
+ 
+ 	      if (tem)
+ 		JUMP_LABEL (tem) = XEXP (jump_label, 0);
+ 
  	      if (nonneg)
  		{
  		  if (tem)
  		    {
  		      /* Increment of LABEL_NUSES done above.  */
  		      /* Register is now always nonnegative,
  			 so add REG_NONNEG note to the branch.  */

Index: unroll.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/unroll.c,v
retrieving revision 1.32
diff -c -3 -p -r1.32 unroll.c
*** unroll.c	1998/10/14 09:02:52	1.32
--- unroll.c	1998/11/14 06:59:44
*************** precondition_loop_p (initial_value, fina
*** 1435,1441 ****
--- 1435,1456 ----
        return 0;
      }
  
+ #if 0
+   /* ??? Note that this does not work if check_dbra_loop reverses the
+      loop since we will return the final iteration variable value for
+      initial_value.
+ 
+      The problem mentioned above for loops, such as "while (i-- > 0)",
+      is not applicable since iteration_info currently rejects GIV
+      iterators.
+      
+      Also note that only the difference between initial_value and
+      final_value is important for calculating the number of loop
+      iterations, not the absolute values.  */
    *initial_value = loop_iteration_var;
+ #else
+   *initial_value = loop_initial_value;
+ #endif
    *increment = loop_increment;
    *final_value = loop_final_value;
  




More information about the Gcc-patches mailing list