fix loop unrolling

Jan Hubicka jh@suse.cz
Mon Jan 21 09:46:00 GMT 2002


Hi,
the final_value computation code has been chagned recently so it can contain
expression of form (plus (val1) (val2)) instead of just generic operand.  The
final_value is then passed to the expanders as operand and works only by
miracle that emit_move_insn (dest, final_value) works and emits existing
add/lea pattern on all platforms.

The result is however loop with number of invariant computations inside.
I am not 100% sure what is the best fix, but it looks sane thing is to
compute new final_value in the header.

Mon Jan 21 17:57:37 CET 2002  Jan Hubicka  <jh@suse.cz>
	* unroll.c (unroll_loop): Lower final_value to generic-operand.

Index: unroll.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/unroll.c,v
retrieving revision 1.144.2.7
diff -c -3 -p -r1.144.2.7 unroll.c
*** unroll.c	2002/01/14 21:18:05	1.144.2.7
--- unroll.c	2002/01/21 16:53:47
*************** unroll_loop (loop, insn_count, strength_
*** 930,935 ****
--- 930,946 ----
  
  	  start_sequence ();
  
+ 	  /* Final value may have form of (PLUS val1 const1_rtx).  We need
+ 	     to convert it into general operand, so compute the real value.  */
+ 
+ 	  if (GET_CODE (final_value) == PLUS)
+ 	    {
+ 	      final_value = expand_simple_binop (mode, PLUS,
+ 						 copy_rtx (XEXP (final_value, 0)),
+ 						 copy_rtx (XEXP (final_value, 1)),
+ 						 NULL_RTX, 0, OPTAB_LIB_WIDEN);
+ 	    }
+ 
  	  /* Calculate the difference between the final and initial values.
  	     Final value may be a (plus (reg x) (const_int 1)) rtx.
  	     Let the following cse pass simplify this if initial value is



More information about the Gcc-patches mailing list