Minor loop patch

Jeffrey A Law law@cygnus.com
Tue Aug 24 22:31:00 GMT 1999


A cleanup Tiemann noticed...    Basically we want to avoid the possibility of
using a divide when we've already performed all the checks we need to be sure
that the division could be done with an arithmetic shift right.


        * loop.c (insert_bct): Replace use of sdiv_optab with asr_optab
        and delete comment that code should be rewritten.

Index: loop.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/loop.c,v
retrieving revision 1.173
diff -c -3 -p -r1.173 loop.c
*** loop.c	1999/08/20 23:05:10	1.173
--- loop.c	1999/08/25 05:27:29
*************** insert_bct (loop_start, loop_end, loop_i
*** 9235,9253 ****
  				   NULL_RTX, 0, OPTAB_LIB_WIDEN);
  
  	if (increment_value_abs != 1)
! 	  {
! 	    /* ??? This will generate an expensive divide instruction for
! 	       most targets.  The original authors apparently expected this
! 	       to be a shift, since they test for power-of-2 divisors above,
! 	       but just naively generating a divide instruction will not give 
! 	       a shift.  It happens to work for the PowerPC target because
! 	       the rs6000.md file has a divide pattern that emits shifts.
! 	       It will probably not work for any other target.  */
! 	    iterations_num_reg = expand_binop (loop_var_mode, sdiv_optab,
! 					       temp_reg,
! 					       GEN_INT (increment_value_abs),
! 					       NULL_RTX, 0, OPTAB_LIB_WIDEN);
! 	  }
  	else
  	  iterations_num_reg = temp_reg;
        }
--- 9235,9244 ----
  				   NULL_RTX, 0, OPTAB_LIB_WIDEN);
  
  	if (increment_value_abs != 1)
! 	  iterations_num_reg = expand_binop (loop_var_mode, asr_optab,
! 					     temp_reg,
! 					     GEN_INT (exact_log2 (increment_value_abs)),
! 					     NULL_RTX, 0, OPTAB_LIB_WIDEN);
  	else
  	  iterations_num_reg = temp_reg;
        }





More information about the Gcc-patches mailing list